Perl Net::ping

        use Net::Ping;
while (1==1){
        $host="202.101.172.35";
        $p = Net::Ping->new("icmp");
        print "$host is lost.\n" unless $p->ping($host,2);
     
}

   $p->close();

$proto
        specifies the protocol to use when doing a ping. The current choices
        are "tcp", "udp", "icmp", "stream", "syn", or "external". The
        default is "tcp".




If a default timeout ($def_timeout) in seconds is provided, it is
        used when a timeout is not given to the ping() method (below). The
        timeout must be greater than 0 and the default, if not specified, is
        5 seconds


如果默认的超时是$def_timeout 单位是秒,用于当没有给ping()方法超时设置

默认5秒,默认5秒不通 返回为假

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