SOL9 Sample: IPv4AddressInfoList
|
1 Screenshot
2 Source code
/*
* IPv4AddressInfoList.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2010/11/28
#include <sol/WSAInitializer.h>
#include <sol/net/IPv4AddressInfoList.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 {
IPv4AddressInfoList infoList;
infoList.getAddrInfo(argv[1]);
int num = infoList.getCount();
_tprintf(_T("IPv4AddressInfoList.getCount(): %d\n"), num);
_tprintf(_T("\nIPv4AddressInfoList.display()\n"));
infoList.display();
_tprintf(_T("\nIPv4AddressInfoList.get IPv4AddressInfo\n"));
IPv4AddressInfo info;
infoList.getNth(0, info);
info.display();
_tprintf(_T("\nIPv4AddressInfoList.get sockaddr_in\n"));
sockaddr_in sockaddr;
infoList.getNth(0, sockaddr);
TCHAR string[128];
IPv4Address ipv4Address;
ipv4Address.toString(&(sockaddr.sin_addr), string);
_tprintf(_T("\nsockaddr.sin_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.