package Net::Ping;
-# $Id: Ping.pm,v 1.15 2001/12/26 20:55:55 rob Exp $
+# $Id: Ping.pm,v 1.16 2002/01/05 23:36:54 rob Exp $
require 5.002;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(pingecho);
-$VERSION = "2.10";
+$VERSION = "2.11";
# Constants
Net::Ping - check a remote host for reachability
-$Id: Ping.pm,v 1.15 2001/12/26 20:55:55 rob Exp $
+$Id: Ping.pm,v 1.16 2002/01/05 23:36:54 rob Exp $
=head1 SYNOPSIS
CHANGES
-------
+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
+ Spotted by craigberry@mac.com (Craig Berry)
+
2.10 Dec 26 12:00 2001
- Added bind() function useful for clients with multiple
network interfaces performing the ping check thanks to
NAME
Net::Ping - check a remote host for reachability
- $Id: Ping.pm,v 1.13 2001/12/07 02:18:44 rob Exp $
+ $Id: Ping.pm,v 1.16 2002/01/05 23:36:54 rob Exp $
SYNOPSIS
use Net::Ping;
$p->close();
$p = Net::Ping->new("icmp");
+ $p->bind($my_addr); # Specify source interface of pings
foreach $host (@host_array)
{
print "$host is ";
otherwise. The maximum number of data bytes that can be specified is
1024.
+ $p->bind($local_addr);
+ Sets the source address from which pings will be sent. This must be
+ the address of one of the interfaces on the local host. $local_addr
+ may be specified as a hostname or as a text IP address such as
+ "192.168.1.1".
+
+ If the protocol is set to "tcp", this method may be called any
+ number of times, and each call to the ping() method (below) will use
+ the most recent $local_addr. If the protocol is "icmp" or "udp",
+ then bind() must be called at most once per object, and (if it is
+ called at all) must be called before the first call to ping() for
+ that object.
+
$p->ping($host [, $timeout]);
Ping the remote host and wait for a response. $host can be either
the hostname or the IP number of the remote host. The optional
module to be written which understands all of the different kinds of
ICMP packets.
-AUTHOR(S)
- Current maintainer Net::Ping base code:
+AUTHORS
+ Current maintainers:
colinm@cpan.org (Colin McMillen)
+ bbb@cpan.org (Rob Brown)
Stream protocol:
bronson@trestle.com (Scott Bronson)
Original Net::Ping author:
mose@ns.ccsn.edu (Russell Mosemann)
- Compatibility porting:
- bbb@cpan.org (Rob Brown)
-
COPYRIGHT
- Copyright (c) 2001, Colin McMillen. All rights reserved. Copyright (c)
- 2001, Rob Brown. All rights reserved.
+ Copyright (c) 2001, Colin McMillen. All rights reserved.
+
+ Copyright (c) 2001, Rob Brown. All rights reserved.
This program is free software; you may redistribute it and/or modify it
under the same terms as Perl itself.
# Everything loaded fine
ok 1;
-my $p = new Net::Ping "tcp";
-ok !!$p;
+if ($> and $^O ne 'VMS') {
+ skip "icmp ping requires root privileges.", 1;
+} else {
+ my $p = new Net::Ping "icmp";
+ ok !!$p;
+}
print "1..0 \# Skip: no Socket\n";
exit;
}
+ unless (getservbyname('echo', 'udp')) {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
}
use Test;
print "1..0 \# Skip: no Socket\n";
exit;
}
+ unless (getservbyname('echo', 'udp')) {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
}
use Test;
print "1..0 \# Skip: no Socket\n";
exit;
}
+ unless (getservbyname('echo', 'udp')) {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
}
use Test;
BEGIN {
- if ($ENV{PERL_CORE}) {
- unless ($ENV{PERL_TEST_Net_Ping}) {
- print "1..0 # Skip: network dependent test\n";
- exit;
- }
- chdir 't' if -d 't';
- @INC = qw(../lib);
- }
- unless (eval "require Socket") {
- print "1..0 \# Skip: no Socket\n";
- exit;
+ if ($ENV{PERL_CORE}) {
+ unless ($ENV{PERL_TEST_Net_Ping}) {
+ print "1..0 # Skip: network dependent test\n";
+ exit;
}
+ chdir 't' if -d 't';
+ @INC = qw(../lib);
+ }
+ unless (eval "require Socket") {
+ print "1..0 \# Skip: no Socket\n";
+ exit;
+ }
+ unless (getservbyname('echo', 'udp')) {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
}
# Remote network test using tcp protocol.
BEGIN {
- if ($ENV{PERL_CORE}) {
- unless ($ENV{PERL_TEST_Net_Ping}) {
- print "1..0 # Skip: network dependent test\n";
- exit;
- }
- chdir 't' if -d 't';
- @INC = qw(../lib);
- }
- unless (eval "require Socket") {
- print "1..0 \# Skip: no Socket\n";
- exit;
+ if ($ENV{PERL_CORE}) {
+ unless ($ENV{PERL_TEST_Net_Ping}) {
+ print "1..0 # Skip: network dependent test\n";
+ exit;
}
+ chdir 't' if -d 't';
+ @INC = qw(../lib);
+ }
+ unless (eval "require Socket") {
+ print "1..0 \# Skip: no Socket\n";
+ exit;
+ }
+ unless (getservbyname('echo', 'udp')) {
+ print "1..0 \# Skip: no echo port\n";
+ exit;
+ }
}
# Test of stream protocol using loopback interface.