SOL9 Sample: IcmpEcho

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


#include <sol/WSAInitializer.h>
#include <sol/icmp/IcmpFile.h>

void main(int argc, char* argv[])
{
  if (argc !=3) {
    printf("Usage: IcmpEcho.exe ipaddress_or_host_name message\n");
    printf("Ex.  IcmpEcho.exe 127.0.0.1 \"Hello world.\"\n");
    return;
  }

  WSAInitializer initializer;

  try {
    const char* ipaddr   = argv[1];
    const char* sendData = argv[2];
  
    IcmpFile icmpFile;
    IcmpEchoReply echoReply;

    icmpFile.sendEcho(ipaddr, sendData, echoReply);

    echoReply.display();

  } catch (Exception err) {
    printf("Exception: %s\n", err.getErrorMessage());
  } catch (DWORD err) {
    printf("Exception: %d\n", err);
  }
}

Last modified: 2 May 2016

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