summaryrefslogtreecommitdiff
path: root/lib/Net
diff options
context:
space:
mode:
authorAndy Dougherty <doughera@lafcol.lafayette.edu>1995-10-31 03:33:09 +0000
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1995-10-31 03:33:09 +0000
commit8e07c86ebc651fe92eb7e3b25f801f57cfb8dd6f (patch)
treebd67a65038befe4bef8b330a688bf7d915cab92f /lib/Net
parente50aee73b3d4c555c37e4b4a16694765fb16c887 (diff)
downloadperl-8e07c86ebc651fe92eb7e3b25f801f57cfb8dd6f.tar.gz
This is my patch patch.1n for perl5.001.perl-5.001n
To apply, change to your perl directory, run the command above, then apply with patch -p1 -N < thispatch. This is a consolidation patch. It contains many of the most commonly applied or agreed-to patches that have been circulating since patch.1m. It also changes the 'unofficial patchlevel' in perl.c. There are some problems (see items marked with '***'). I will attempt to address those in a patch.1o in a few days. This patch contains the following packages: My Jumbo Configure patch vs. 1m, with subsequent patches 1, 2, and 3. Mainly, this provides easier use of local libraries, documents the installation process in a new INSTALL file, moves important questions towards the beginning, and improves detection of signal names (mostly for Linux). xsubpp-1.922. Patches from Larry: eval "1" memory leak patch (as modified by GSAR to apply to 5.001m). NETaa14551 Infinite loop in formats, NETaa13729 scope.c patch (fixed problems on AIX and others) NETaa14138 "substr() & s///" (pp_hot.c) Patches from ftp.perl.com: ftp://ftp.perl.com/pub/perl/src/patches/closure-bug.patch, version of 20 Sep 1995 Includes fix for NETaa14347 (32k limit in regex), and other fixes. ftp://ftp.perl.com/pub/perl/src/patches/debugger.patch, version of 27 Aug 1995 ftp://ftp.perl.com/pub/perl/src/patches/glob-undef.patch, version of 4 Sep 1995 NETaa14421 $_ doesn't undef ftp://ftp.perl.com/pub/perl/src/patches/op-segfault.patch, version of 21 Aug 1995 ftp://ftp.perl.com/pub/perl/src/patches/warn-ref-hash-key.patch, version of 5 Jun 1995 Tim Bunce's Jumbo DynaLoader patch for Perl5.001m, which is NETaa14636 Jumbo DynaLoader patch for Perl5.001m, and Additional patch for NETaa14636 Jumbo DynaLoader patch for Perl5.001m version of 09 Oct 1995. ***This needs some additional parentheses.*** MakeMaker-5.00. Supercedes NETaa13540 (VMS MakeMaker patches). (Updates minimod.PL as well.) ***This has a couple of minor problems. pod2man is run even if it isn't available. LD_RUN_PATH gets set to some mysterious values.*** NETaa14657 Paul Marquess Net::Ping patch. I've included Net-Ping-1.00. NETaa14661 Dean Roehrich DProf. Installed as ext/Devel/DProf. Configure should pick this up automatically. (5 Apr 1995 version.) NETaa13742 Jack Shirazi Socket in 5.001. I've also included his socket.t test in t/lib/socket.t. c2ph-1.7. Dean's perlapi patches of Oct 12, 1995, which superceded those of Oct 8, 1995. This is the one that did mv perlapi.pid perlxs.pod. NETaa14310 Tim Bunce A trivial patch for configpm (handy for shell scripts) DB_File-1.0 patch from Paul Marquess (pmarquess@bfsec.bt.co.uk) last modified 7th October 1995 version 1.0 Added or updated the following hints files: hints/hpux.sh hints/ncr_tower.sh hints/netbsd.sh hints/ultrix.sh Patch and enjoy. Andy Dougherty doughera@lafcol.lafayette.edu Dept. of Physics Lafayette College, Easton PA 18042
Diffstat (limited to 'lib/Net')
-rw-r--r--lib/Net/Ping.pm127
1 files changed, 66 insertions, 61 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm
index cfc8f9f6a1..92d595eec9 100644
--- a/lib/Net/Ping.pm
+++ b/lib/Net/Ping.pm
@@ -1,44 +1,5 @@
package Net::Ping;
-=head1 NAME
-
-Net::Ping, pingecho - check a host for upness
-
-=head1 SYNOPSIS
-
- use Net::Ping;
- print "'jimmy' is alive and kicking\n" if pingecho('jimmy', 10) ;
-
-=head1 DESCRIPTION
-
-This module contains routines to test for the reachability of remote hosts.
-Currently the only routine implemented is pingecho().
-
-pingecho() uses a TCP echo (I<not> an ICMP one) to determine if the
-remote host is reachable. This is usually adequate to tell that a remote
-host is available to rsh(1), ftp(1), or telnet(1) onto.
-
-=head2 Parameters
-
-=over 5
-
-=item hostname
-
-The remote host to check, specified either as a hostname or as an IP address.
-
-=item timeout
-
-The timeout in seconds. If not specified it will default to 5 seconds.
-
-=back
-
-=head1 WARNING
-
-pingecho() uses alarm to implement the timeout, so don't set another alarm
-while you are using it.
-
-=cut
-
# Authors: karrer@bernina.ethz.ch (Andreas Karrer)
# pmarquess@bfsec.bt.co.uk (Paul Marquess)
@@ -46,27 +7,34 @@ require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(ping pingecho);
+$VERSION = 1.00;
-use Socket;
-use Carp ;
+use Socket 'PF_INET', 'AF_INET', 'SOCK_STREAM';
+require Carp ;
-$tcp_proto = (getprotobyname('tcp'))[2];
-$echo_port = (getservbyname('echo', 'tcp'))[2];
+use strict ;
+
+$Net::Ping::tcp_proto = (getprotobyname('tcp'))[2];
+$Net::Ping::echo_port = (getservbyname('echo', 'tcp'))[2];
+
+# keep -w happy
+$Net::Ping::tcp_proto = $Net::Ping::tcp_proto ;
+$Net::Ping::echo_port = $Net::Ping::echo_port ;
sub ping {
- croak "ping not implemented yet. Use pingecho()";
+ Carp::croak "ping not implemented yet. Use pingecho()";
}
sub pingecho {
- croak "usage: pingecho host [timeout]"
+ Carp::croak "usage: pingecho host [timeout]"
unless @_ == 1 || @_ == 2 ;
- local ($host, $timeout) = @_;
+ my ($host, $timeout) = @_;
+ my ($saddr, $ip);
+ my ($ret) ;
local (*PINGSOCK);
- local ($saddr, $ip);
- local ($ret) ;
# check if $host is alive by connecting to its echo port, within $timeout
# (default 5) seconds. returns 1 if OK, 0 if no answer, 0 if host not found
@@ -80,24 +48,61 @@ sub pingecho {
return 0 unless $ip; # "no such host"
- $saddr = pack('S n a4 x8', AF_INET, $echo_port, $ip);
+ $saddr = pack('S n a4 x8', AF_INET, $Net::Ping::echo_port, $ip);
$SIG{'ALRM'} = sub { die } ;
alarm($timeout);
-
- $ret = eval <<'EOM' ;
-
- return 0
- unless socket(PINGSOCK, PF_INET, SOCK_STREAM, $tcp_proto) ;
-
- return 0
- unless connect(PINGSOCK, $saddr) ;
-
- return 1 ;
+
+ $ret = 0;
+ eval <<'EOM' ;
+ return unless socket(PINGSOCK, PF_INET, SOCK_STREAM, $Net::Ping::tcp_proto) ;
+ return unless connect(PINGSOCK, $saddr) ;
+ $ret=1 ;
EOM
-
alarm(0);
close(PINGSOCK);
- $ret == 1 ? 1 : 0 ;
+ $ret;
}
1;
+__END__
+
+=cut
+
+=head1 NAME
+
+Net::Ping, pingecho - check a host for upness
+
+=head1 SYNOPSIS
+
+ use Net::Ping;
+ print "'jimmy' is alive and kicking\n" if pingecho('jimmy', 10) ;
+
+=head1 DESCRIPTION
+
+This module contains routines to test for the reachability of remote hosts.
+Currently the only routine implemented is pingecho().
+
+pingecho() uses a TCP echo (I<not> an ICMP one) to determine if the
+remote host is reachable. This is usually adequate to tell that a remote
+host is available to rsh(1), ftp(1), or telnet(1) onto.
+
+=head2 Parameters
+
+=over 5
+
+=item hostname
+
+The remote host to check, specified either as a hostname or as an IP address.
+
+=item timeout
+
+The timeout in seconds. If not specified it will default to 5 seconds.
+
+=back
+
+=head1 WARNING
+
+pingecho() uses alarm to implement the timeout, so don't set another alarm
+while you are using it.
+
+