From: Jarkko Hietaniemi Date: Sun, 30 Mar 2003 08:31:53 +0000 (+0000) Subject: gethostbyname('localhost') is not that portable. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ef5a6dd776ac4bf49f73d33c2c15049c102661c0;p=p5sagit%2Fp5-mst-13.2.git gethostbyname('localhost') is not that portable. inet_aton('localhost') in IRIX 5.3 returned an undef, which in turn made pack_sockaddr_in to barf on zero length in_addr. p4raw-id: //depot/perl@19084 --- diff --git a/ext/Socket/Socket.t b/ext/Socket/Socket.t index c06b9e7..a5ad264 100755 --- a/ext/Socket/Socket.t +++ b/ext/Socket/Socket.t @@ -26,8 +26,11 @@ if (socket(T,PF_INET,SOCK_STREAM,6)) { print "ok 1\n"; arm(5); - my $host = $^O eq 'MacOS' ? '127.0.0.1' : 'localhost'; - if ($has_echo && connect(T,pack_sockaddr_in(7,inet_aton($host)))){ + my $host = $^O eq 'MacOS' || ($^O eq 'irix' && $Config{osvers} == 5) ? + '127.0.0.1' : 'localhost'; + my $localhost = inet_aton($host); + + if ($has_echo && defined $localhost && connect(T,pack_sockaddr_in(7,$localhost))){ arm(0); print "ok 2\n"; @@ -53,7 +56,9 @@ if (socket(T,PF_INET,SOCK_STREAM,6)) { } else { print "# You're allowed to fail tests 2 and 3 if\n"; - print "# the echo service has been disabled.\n"; + print "# the echo service has been disabled or if your + print "# gethostbyname() cannot resolve your localhost.\n"; + print "# 'Connection refused' indicates disabled echo service.\n"; print "# 'Interrupted system call' indicates a hanging echo service.\n"; print "# Error: $!\n"; print "ok 2 - skipped\n"; diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 353e4e6..d3eb002 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -224,8 +224,8 @@ by this are: C<-X>, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, -C, C, C, C, C, C, -C, C, C, C, +C, C, C, C, C, C, +C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, diff --git a/pod/perlport.pod b/pod/perlport.pod index d74c0da..b6aca78 100644 --- a/pod/perlport.pod +++ b/pod/perlport.pod @@ -1636,6 +1636,11 @@ Not implemented. (S, Win32, VM/ESA) Not implemented. (S, Win32, VMS, VM/ESA) +=item gethostbyname + +C does not work everywhere: you may have +to use C. (S, S) + =item gethostent Not implemented. (S, Win32)