# Embedded Ping Class

Topics

:

Overview
Conditional Directives
Constants
Type Definitions
Enumerations
Data Structures
Data Members
Functions

Overview

The embedded ping class is a cross platform ping implementation use to test connectivity between Internet host using ICMP (Internet Control Message Protocol) and raw sockets.

Public Data Members

gxSocket * gxsPing::raw_socket

- Public data member that points the previously opened socket.

gxsEchoRequest gxsPing::echo_request

- Echo request header.

gxsEchoReply gxsPing::echo_reply

- Echo reply header.

int gxsPing::time_sent

- Public data member the records the time the packet was sent.

int gxsPing::elapsed_time

- Public data member the records the time in millisecond for the packet to return.

int gxsPing::time_to_live

- Public data member the records the time to live.

Functions

gxsPing::gxsPing()
gxsPing::~gxsPing()
gxsPing::Ping()
gxsPing::RecvEchoReply()
gxsPing::SendEchoRequest()
gxsPing::WaitForEchoReply()

gxsPing::gxsPing(gxSocket *s)

- Class constructor used to construct a ping object. The socket variable must point to a previously opened and initialized socket, for example:

    gxSocket raw_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP, 0, hostname);

NOTE

: Under all UNIX platforms you must have root privileges to use raw sockets. Windows 95/98/ME/NT only works with the IPPROTO_ICMP protocol when using raw sockets and does not support the IPPROTO_RAW protocol.

gxsPing::~gxsPing()

- Class destructor.

gxSocketError gxsPing::Ping(int time_out_sec = 1, int time_out_usec = 0)

- Public member function used to ping an Internet host with a specified time out value. Return zero if successful or a non-zero value corresponding to one of the integer constants defined in the error code enumeration if any failures occur.

gxSocketError gxsPing::RecvEchoReply()

- Public member function used to receive the echo reply. Return zero if successful or a non-zero value corresponding to one of the integer constants defined in the error code enumeration if any failures occur.

gxSocketError gxsPing::SendEchoRequest()

- Public member function used to send the echo request. Return zero if successful or a non-zero value corresponding to one of the integer constants defined in the error code enumeration if any failures occur.

int gxsPing::WaitForEchoReply(int time_out_sec = 1, int time_out_usec = 0)

- Public member function used to wait for the echo reply using the select function to signal when data is waiting to be read. Returns false if the request times out when the specified timeout value is reached.

End Of Document