AHK library providing a variety of ICMP pinging-related functionality.
Examples
Ping a Google DNS server:
MsgBox % “Round trip time: ” . RoundTripTime(“8.8.8.8”)
Ping two different Google DNS servers at the same time:
Addresses := [“8.8.8.8”, “8.8.4.4”]
Value := “”
For Index, PingTime In RoundTripTimeList(Addresses)
Value .= “Server: “List[Index] . “, Round trip time: ” . PingTime . “ms`n”
MsgBox %Value%
Send an ICMP request to a Google DNS server:
MsgBox % “Round trip time: ” . Ping(“8.8.8.8”) . “ms”
Ping example.com with some data and show the response (the SubStr causes the result to be interpreted as a string):
MsgBox % “Round trip time: ” . Ping(“192.0.43.10″,800,”Hello!”,6,Value,Length) . “ms, Response: ” . SubStr(Value,1)
Overview
All functions throw exceptions on failure.
### RTT := Ping(Address,Timeout = 800,ByRef Data = “”,Length = 0,ByRef Result = “”,ByRef ResultLength = 0)
Pings an address and waits for a response.
Useful for sending custom pings supporting messages and responses.
### RTT := PingAsync(Address,Timeout = 800,ByRef Data = “”,Length = 0,ByRef Result = “”,ByRef ResultLength = 0)
Works exactly the same as Ping(), but uses an asynchronous event-based method.
Intended only as a technology demo, avoid using as it may change or be removed in the future.
### RTT := RoundTripTime(Address,Timeout = 800)
Determines the round trip time (sometimes called the “ping”) from the local machine to the address.
Useful for pinging a server to determine latency.
### RTT := RoundTripTimeList(AddressList,Timeout = 800)
Determines the round trip time (sometimes called the “ping”) from the local machine to a list of 64 or fewer addresses.
Useful for quickly pinging an entire server list to find the amount of latency in the connection to each.
Parameters
RTT: The round trip time in milliseconds (e.g., 76). If unknown or timed out, this value is -1.
Address: IPv4 address as a string in dotted number format (e.g., “127.0.0.1”).
AddressList: Array of IPv4 addresses as strings in dotted number format (e.g., [“127.0.0.1”, “8.8.4.4”]).
Timeout: How long the function should wait, in milliseconds, before giving an error (e.g., 400).
Data: The data to send with the ping (e.g., “Hello”). Can be binary data as well.
Length: The length of the data to send with the ping (e.g., 5).
Result: The data in the response to the ping (e.g., “Salutations”). Can be binary data as well.
ResultLength: The length of the data in the response to the ping (e.g., 11).