SOL9 Sample: IcmpEcho

SOL9 Samples

1 Screenshot


2 Source code

/*
 * IcmpEcho.cpp 
 * Copyright (c) 2010 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;

        DWORD rc = 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: 1 Nov 2010

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