Net::Ping 模块详解

NAME
    Net::Ping - check a remote host for reachability

检查远程主机是否可达

SYNOPSIS

简介
        use Net::Ping;

        $p = Net::Ping->new();
        print "$host is alive.\n" if $p->ping($host);
        $p->close();



        $p = Net::Ping->new("icmp");
        $p->bind($my_addr); # Specify source interface of pings
        foreach $host (@host_array)
        {
            print "$host is ";
            print "NOT " unless $p->ping($host, 2);
            print "reachable.\n";
            sleep(1);
        }
        $p->close();



        $p = Net::Ping->new("tcp", 2);
        # Try connecting to the www port instead of the echo port
        $p->port_number(getservbyname("http", "tcp"));
        while ($stop_time > time())
        {
            print "$host not reachable ", scalar(localtime()), "\n"
                unless $p->p

你可能感兴趣的:(Perl高级编程)