SOL9 Sample: IPv6StringToAddress

SOL9 Samples

1 Screenshot


2 Source code

/*
 * IPv6StringToAddress.cpp 
 * Copyright (c) 2010 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2010/10/30

#include <sol/net/IPv6String.h>
#include <sol/net/IPv6Address.h>


// Sample program to convert a IPv6String to an address.

void main(int argc, char** argv)
{
    try {
        // Specify "::1" for IPv6 localhost.
        if (argc != 2) {
            printf("Usage: %s IPv6String\n", argv[0]);
            printf("Specify ::1 for IPv6 localhost.\n");
            return;
        }

        char* string = "::1";
        string = argv[1];

        printf("IPv6 IPv6String %s\n", string);

        IPv6String  v6String;

        char* delim = NULL;
        IN6_ADDR address;
        v6String.toAddress(string, &delim, &address);
        printf("Converted to IN6_ADDR\n");        

        char convstring[64];
        IPv6Address v6Address;

        v6Address.toString(&address, convstring);
            
        printf("Converted to IPv6String %s\n", convstring);

    } catch (int err) {
        printf("Exception %d\n", err);    
    }
}

Last modified: 1 Nov 2010

Copyright (c) 2010 Antillia.com ALL RIGHTS RESERVED.