Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.66 KB

File metadata and controls

51 lines (36 loc) · 1.66 KB

Home

How to ping a remote site using IP Helper API calls

Before you begin:

An article "A New Way to Ping" published on CodeGuru pages by Bill Nolde is a source for this example, which is a direct C++ to VFP translation.

Another example shows how to convert a host name (like "www.myhost.com", "microsoft.com", "aol.com" etc.) to IP address in dotted format (like 192.168.0.1).

See also:


Code:

DO declare

LOCAL nDst, nHop, nRTT
nDst = inet_addr("212.58.244.67")  && bbc news

STORE 0 TO nHop, nRTT

IF GetRTTAndHopCount(nDst, @nHop, 50, @nRTT) <> 0
	? "Hop count to the destination:", nHop
	? "Round-trip time, in milliseconds:", nRTT
ELSE
* on error, GetLastError may still return zero
	? "Error"
ENDIF
* end of main

PROCEDURE declare
	DECLARE INTEGER GetRTTAndHopCount IN Iphlpapi;
		INTEGER DestIpAddress, LONG @HopCount,;
		INTEGER MaxHops, LONG @RTT

	DECLARE INTEGER inet_addr IN ws2_32 STRING cp  

Listed functions:

GetLastError
GetRTTAndHopCount
inet_addr