SOL9 Sample: AddressInfoListForServices

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL9
// 2010/11/28
#include <sol/WSAInitializer.h>
#include <sol/net/AddressInfoList.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;
  const TCHAR* services[] = {_T("http"), _T("telnet"), 
      _T("ftp"), _T("smtp"), _T("pop3"), _T("imap4"), _T("ping"), _T("finger"),};

  for (int i = 0; i<SizeOf(services); i++) {

    try {
      _tprintf(_T("Service: %s\n"), services[i]);
    
      AddressInfoList infoList;
      infoList.getAddrInfo(argv[1], services[i]);
      int num = infoList.getCount();
      _tprintf(_T("AddressInfoList.getCount(): %d\n"), num);

      _tprintf(_T("AddressInfoList.display()\n"));
      infoList.display();

    } catch (Exception& ex) {
      ex.printf();
    } catch (...) {
      _tprintf(_T("Exception\n"));
    }
    _tprintf(_T("---\n"));
  }
}

Last modified: 2 May 2016

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