SOL9 Sample: IPv6StringToAddress

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL9
// 2010/10/30
// 2010 Modified for UNICODE

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

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

void _tmain(int argc, TCHAR** argv)
{
  try {
    Locale locale;
    // Specify "::1" for IPv6 localhost.
    if (argc != 2) {
      _tprintf(_T("Usage: %s IPv6String\n"), argv[0]);
      _tprintf(_T("Specify ::1 for IPv6 localhost.\n"));
      return;
    }

    TCHAR* string = _T("::1");
    string = argv[1];

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

    IPv6String  v6String;

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

    TCHAR convstring[128];
    IPv6Address v6Address;

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

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

Last modified: 2 May 2016

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