[Chapter 7] 7.2.46 Net::Ping - Check Whether a Host Is Online
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T02:03:01Z

#

| Chapter 7 The Standard Perl Library |

### 7.2.46 Net::Ping - Check Whether a Host Is Online

    use Net::Ping;

    $hostname = 'elvis';       # host to check
    $timeout = 10;             # how long to wait for a response
    print "elvis is alive\n"    if pingecho($hostname, $timeout);

`pingecho()` uses a TCP echo (not an ICMP one) to determine whether a remote host is reachable. This is usually adequate to tell whether a remote host is available to rsh(1), ftp(1), or telnet(1).

The parameters for `pingecho()` are:

hostname

  The remote host to check, specified either as a hostname or as an IP address.

timeout

  The timeout in seconds. If not specified it will default to 5 seconds.

> WARNING: `pingecho()` uses alarm to implement the timeout, so don't set another alarm while you are using it.

7.2.45 NDBM_File - Tied Access to NDBM Files |  | 7.2.47 ODBM_File - Tied Access to ODBM Files