SOL9 Sample: IPv6AddressInfoList
|
1 Screenshot
2 Source code
/*
* IPv6AddressInfoList.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2010/11/28
#include <sol/WSAInitializer.h>
#include <sol/net/IPv6AddressInfoList.h>
#include <sol/Locale.h>
void _tmain(int argc, TCHAR** argv)
{
if (argc !=2) {
_tprintf(_T("Usage:%s ipaddr_or_hostname\n"), argv[0]);
return;
}
WSAInitializer initializer;
Locale locale;
try {
IPv6AddressInfoList infoList;
infoList.getAddrInfo(argv[1]);
int num = infoList.getCount();
_tprintf(_T("IPv6AddressInfoList.getCount(): %d\n"), num);
_tprintf(_T("\nIPv6AddressInfoList.display()\n"));
infoList.display();
_tprintf(_T("\nIPv6AddressInfoList.get IPv6AddressInfo\n"));
IPv6AddressInfo info;
infoList.getNth(0, info);
info.display();
_tprintf(_T("\nIPv6AddressInfoList.get sockaddr_in6\n"));
sockaddr_in6 sockaddr;
infoList.getNth(0, sockaddr);
TCHAR string[128];
IPv6Address ipv6Address;
ipv6Address.toString(&(sockaddr.sin6_addr), string);
_tprintf(_T("\nsockaddr.sin6_addr: %s\n"), string);
} catch (Exception& ex) {
ex.printf();
} catch (...) {
_tprintf(_T("Exception\n"));
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.