Summary
Pings the specified host.
Syntax
local success, pingResults = ping(hostAddress, packetCount, packetSize, ttl)Parameters
hostAddress : IP address or hostname to ping. packetCount : Number of packets to send. Optional parameter; default value is 4. packetSize : Size in bytes of the packets to be sent. Optional parameter; default value is 32. ttl : Time to live parameter of the ICMP message. Optional parameter; default value is 128.
Returns
success : Boolean value, set to true if one packet, or more, is received.
pingResults : Table containing the results, with the following fields:
- packets_transmitted : Total number of packets that were sent.
- packets_received : Total number of packets that were received.
- min_time : Minimum round-trip time, in milliseconds.
- max_time : Maximum round-trip time, in milliseconds.
- avg_time : Average round-trip time, in milliseconds.
- stddev : Standard deviation of the measurement.
- error : Error message, if any.
Description
Sends one or more (ICMP) echo messages with the specified packet size to the computer that has the specified address, and receives the corresponding ICMP echo reply messages from that computer.
Note that ping is not a fail-safe method for determining the availability of a remote computer, since the ping port on the target host may be turned off or the ping request may be blocked by a firewall. The address passed to the Ping method must be DNS resolvable and cannot be preceded by "http://".
Examples
local pingOk, pingResult = ping('www.anfibia-soft.com', 4, 32, 128)
if pingOk then
print('Host responded: ' .. pingResult.packets_received .. '/' .. pingResult.packets_transmitted)
else
print('Host did not respond. Cause: ' .. pingResult.error)
end