CPing v1.21
Welcome to CPing, a freeware MFC class to encapsulate the PING protocol.
Features |
Usage |
History |
API Reference |
Planned Enhancements |
Contacting the Author |
V1.0 (11th June 1998)
V1.1 (23rd June 1998)
V1.2 (30th July 1998)
V1.21 (9th November 1998)
The API consists of the the single public member "Ping" of the class CPing
CPing::Ping1
BOOL CPing::Ping1(LPCTSTR pszHostName, CPingReply& pr, UCHAR nTTL = 10, DWORD dwTimeout = 5000, UCHAR nPacketSize = 32) const
Return Value
If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call ::GetLastError.
Parameters
pszHostName The network address of the socket to connect to: a machine name such as ftp.yourisp.com, or a dotted number such as 128.56.22.8 will both work.
pr This is a reference to a structure which will be filled in upon successful return of this function. Currently it contains just two members, namely:
Address This is th IP address of the replier
RTT This is the round trip time in Milliseconds
dwTimeout This is the timeout to use for connections in milliseconds.
nTTL This is the time to live of the ICMP packet to be sent. For those unfamilar with the low level details of IP, this is the maximum number of routers through which this packet should travel. Each time an IP packet goes through a router, its TTL value is decremented by 1. Eventually when a packet is received with a TTL of 1, it is not forwarded and instead an ICMP reply is generated. This prevents the network from becoming flooded with old IP packets. As an aside this is the basis of how traceroute is implemented.
nPacketSize This is the size of the ICMP packet to send.
Remarks
Internally this function will use the ICMP dll to do a ping. To make this function available you will need to define the CPING_USE_ICMP preprocessor macro and link to the winsock v1.1dll namely "wsock32.dll".
CPing::Ping2
BOOL CPing::Ping2(LPCTSTR pszHostName, CPingReply& pr, DWORD dwTimeout = 5000, UCHAR nTTL = 10, UCHAR nPacketSize = 32) const
Return Value
If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call ::GetLastError.
Parameters
pszHostName The network address of the socket to connect to: a machine name such as ftp.yourisp.com, or a dotted number such as 128.56.22.8 will both work.
pr This is a reference to a structure which will be filled in upon successful return of this function. Currently it contains just two members, namely:
Address This is th IP address of the replier
RTT This is the round trip time in Milliseconds
dwTimeout This is the timeout to use for connections in milliseconds.
nTTL This is the time to live of the ICMP packet to be sent. For those unfamilar with the low level details of IP, this is the maximum number of routers through which this packet should travel. Each time an IP packet goes through a router, its TTL value is decremented by 1. Eventually when a packet is received with a TTL of 1, it is not forwarded and instead an ICMP reply is generated. This prevents the network from becoming flooded with old IP packets. As an aside this is the basis of how traceroute is implemented.
nPacketSize This is the size of the ICMP packet to send.
Remarks
Internally this function will use the raw winsock 2 calls to do a ping. To make this function available you will need to define the CPING_USE_WINSOCK2 preprocessor macro and link to the winsock v2 dll, namely ws2_32.lib. Please note that this dll is only available on NT or recent service packs of Windows 95 and is not available on the original build of 95, namely build 950.
PJ Naughter
Email: pjn@indigo.ie
Web: http://indigo.ie/~pjn
9th November 1998