#
# Authors of the original pingecho():
# karrer@bernina.ethz.ch (Andreas Karrer)
-# pmarquess@bfsec.bt.co.uk (Paul Marquess)
+# Paul.Marquess@btinternet.com (Paul Marquess)
#
# Copyright (c) 1996 Russell Mosemann. All rights reserved. This
# program is free software; you may redistribute it and/or modify it
# under the same terms as Perl itself.
-require 5.002;
+use 5.005_64;
require Exporter;
use strict;
-use vars qw(@ISA @EXPORT $VERSION
- $def_timeout $def_proto $max_datasize);
+our(@ISA, @EXPORT, $VERSION, $def_timeout, $def_proto, $max_datasize);
use FileHandle;
use Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET
inet_aton sockaddr_in );
}
elsif ($self->{"proto"} eq "icmp")
{
- croak("icmp ping requires root privilege") if $>;
+ croak("icmp ping requires root privilege") if ($> and $^O ne 'VMS');
$self->{"proto_num"} = (getprotobyname('icmp'))[2] ||
croak("Can't get icmp protocol by name");
$self->{"pid"} = $$ & 0xffff; # Save lower 16 bits of pid
sleep(1);
}
$p->close();
-
+
$p = Net::Ping->new("tcp", 2);
while ($stop_time > time())
{
sleep(300);
}
undef($p);
-
+
# For backward compatibility
print "$host is alive.\n" if pingecho($host);
parameters, a variable number of hosts may be pinged multiple
times and then the connection is closed.
-You may choose one of three different protocols to use for the ping.
+You may choose one of three different protocols to use for the
+ping. The "udp" protocol is the default. Note that a live remote host
+may still fail to be pingable by one or more of these protocols. For
+example, www.microsoft.com is generally alive but not pingable.
+
With the "tcp" protocol the ping() method attempts to establish a
connection to the remote host's echo port. If the connection is
successfully established, the remote host is considered reachable. No