develooper Front page | perl.perl5.porters | Postings from March 2003

[PATCH] Net::Ping

From:
Slaven Rezic
Date:
March 28, 2003 07:43
Subject:
[PATCH] Net::Ping
Message ID:
200303281526.h2SFQCx8031405@vran.herceg.de
There's still a failing test in Net::Ping when not connected to the
internet. Here's a patch:

--- bleedperl/lib/Net/Ping.pm	Tue Mar 11 07:47:08 2003
+++ bleedperl2/lib/Net/Ping.pm	Fri Mar 28 16:05:29 2003
@@ -9,7 +9,7 @@ use vars qw(@ISA @EXPORT $VERSION
 use Fcntl qw( F_GETFL F_SETFL O_NONBLOCK );
 use Socket qw( SOCK_DGRAM SOCK_STREAM SOCK_RAW PF_INET SOL_SOCKET
                inet_aton inet_ntoa sockaddr_in );
-use POSIX qw( ECONNREFUSED EINPROGRESS EAGAIN WNOHANG );
+use POSIX qw( ECONNREFUSED EINPROGRESS EAGAIN WNOHANG EHOSTUNREACH ENETUNREACH );
 use FileHandle;
 use Carp;
 
@@ -516,6 +516,8 @@ sub tcp_connect
     if (!connect($self->{"fh"}, $saddr)) {
       if ($! == ECONNREFUSED) {
         $ret = 1 unless $self->{"tcp_econnrefused"};
+      } elsif ($! == ENETUNREACH || $! == EHOSTUNREACH) {
+	$ret = undef;
       } else {
         # EINPROGRESS is the expected error code after a connect()
         # on a non-blocking socket


-- 
Slaven Rezic - slaven@rezic.de

    tktimex - project time manager
    http://sourceforge.net/projects/ptktools/



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About