package Net::Ping;
-# $Id: Ping.pm,v 1.16 2002/01/05 23:36:54 rob Exp $
+# $Id: Ping.pm,v 1.17 2002/02/18 01:25:11 rob Exp $
require 5.002;
require Exporter;
use Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET
inet_aton sockaddr_in );
use Carp;
+use Errno qw(ECONNREFUSED);
@ISA = qw(Exporter);
@EXPORT = qw(pingecho);
-$VERSION = "2.11";
+$VERSION = "2.12";
# Constants
my ($ret # The return value
);
- $@ = "";
+ $@ = ""; $! = 0;
$ret = $self -> tcp_connect( $ip, $timeout);
- $ret = 1 if $@ =~ /(Connection Refused|Unknown Error)/i;
+ $ret = 1 if $! == ECONNREFUSED # Connection refused
+ || $@ =~ /Unknown Error/i; # Special Win32 response?
$self->{"fh"}->close();
return($ret);
}
Net::Ping - check a remote host for reachability
-$Id: Ping.pm,v 1.16 2002/01/05 23:36:54 rob Exp $
+$Id: Ping.pm,v 1.17 2002/02/18 01:25:11 rob Exp $
=head1 SYNOPSIS
CHANGES
-------
+2.12 Feb 17 19:00 2002
+ - More general error determination for
+ better cross platform consistency and
+ foreign language support.
+ Spotted by arnaud@romeconcept.com
+ - Test changes for VMS (Craig Berry)
+
2.11 Feb 02 12:00 2002
- Test changes in case echo port is not available.
- Fix 110_icmp_inst.t to use icmp protocol
NAME
Net::Ping - check a remote host for reachability
- $Id: Ping.pm,v 1.16 2002/01/05 23:36:54 rob Exp $
+ $Id: Ping.pm,v 1.17 2002/02/18 01:25:11 rob Exp $
SYNOPSIS
use Net::Ping;
# Everything loaded fine
ok 1;
-if ($> and $^O ne 'VMS') {
+if (($> and $^O ne 'VMS')
+ or ($^O eq 'VMS'
+ and (`write sys\$output f\$privilege("SYSPRV")` =~ m/FALSE/))) {
skip "icmp ping requires root privileges.", 1;
} else {
my $p = new Net::Ping "icmp";