Provides methods to create ping objects and test the reachability of remote hosts on the network. After the object has been created, a variable number of hosts can be pinged multiple times before closing the connection. The methods are the following.
new |
Creates a new ping object. All arguments are optional. Takes the following arguments:
proto The protocol to use when doing a ping. Default is udp. The possible protocols are:
icmp Sends an icmp echo message to the remote host. If the echoed message is received back correctly from the remote host, that host is considered reachable. Requires the program to be run as root or setuid to root.
tcp Attempts to establish connection to remote host's echo port. If successful, remote host is considered reachable. No data is actually echoed. No special privileges are required, but overhead is higher than for the others.
udp Sends a udp packet to remote host's echo port. If the echoed packet is received back from the remote host and contains the same data that was sent, the remote host is considered reachable. Requires no special privileges.
def_timeout Default timeout in seconds to be used if timeout not passed to the ping method. Must be greater than zero; defaults to five seconds.
bytes Number of bytes included in the ping packet sent to the remote host. Ignored if protocol is tcp. Default is 1 if protocol is udp, otherwise 0. These are also the minimum number of bytes; the maximum is 1,024.
close |
Closes network connection for this ping object. The connection can also be closed by undef $p and is automatically closed if the ping object goes out of scope.
ping |
Pings remote host and waits for a response. Takes the following arguments:
host Specified as either the hostname or the IP number of the remote host.
timeout Optional, must be greater than 0 seconds if specified. Defaults to whatever was specified when the ping object was created.
If host cannot be found, or if there is a problem with the IP number, returns undef. Otherwise, returns 1 if the host is reachable and 0 if it is not.
pingecho |
Provides backward compatibility with the previous version of Net::Ping. Uses the tcp protocol, with return values and parameters the same as described for ping.
8.158. Net::NNTP | 8.160. Net::POP3 |
Copyright © 2002 O'Reilly & Associates. All rights reserved.