summaryrefslogtreecommitdiffstats
path: root/contrib/perl5/t/lib/io_sock.t
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/perl5/t/lib/io_sock.t')
-rwxr-xr-xcontrib/perl5/t/lib/io_sock.t30
1 files changed, 18 insertions, 12 deletions
diff --git a/contrib/perl5/t/lib/io_sock.t b/contrib/perl5/t/lib/io_sock.t
index 056d131f..45c16c2 100755
--- a/contrib/perl5/t/lib/io_sock.t
+++ b/contrib/perl5/t/lib/io_sock.t
@@ -3,7 +3,7 @@
BEGIN {
unless(grep /blib/, @INC) {
chdir 't' if -d 't';
- unshift @INC, '../lib' if -d '../lib';
+ @INC = '../lib';
}
}
@@ -70,17 +70,15 @@ if($pid = fork()) {
} elsif(defined $pid) {
- # This can fail if localhost is undefined or the
- # special 'loopback' address 127.0.0.1 is not configured
- # on your system. (/etc/rc.config.d/netconfig on HP-UX.)
- # As a shortcut (not recommended) you could change 'localhost'
- # here to be the name of this machine eg 'myhost.mycompany.com'.
-
$sock = IO::Socket::INET->new(PeerPort => $port,
Proto => 'tcp',
PeerAddr => 'localhost'
)
- or die "$! (maybe your system does not have the 'localhost' address defined)";
+ || IO::Socket::INET->new(PeerPort => $port,
+ Proto => 'tcp',
+ PeerAddr => '127.0.0.1'
+ )
+ or die "$! (maybe your system does not have a localhost at all, 'localhost' or 127.0.0.1)";
$sock->autoflush(1);
@@ -114,7 +112,8 @@ if($pid = fork()) {
$listen->close;
} elsif (defined $pid) {
# child, try various ways to connect
- $sock = IO::Socket::INET->new("localhost:$port");
+ $sock = IO::Socket::INET->new("localhost:$port")
+ || IO::Socket::INET->new("127.0.0.1:$port");
if ($sock) {
print "not " unless $sock->connected;
print "ok 6\n";
@@ -151,7 +150,9 @@ if($pid = fork()) {
sleep(1);
$sock = IO::Socket->new(Domain => AF_INET,
- PeerAddr => "localhost:$port");
+ PeerAddr => "localhost:$port")
+ || IO::Socket->new(Domain => AF_INET,
+ PeerAddr => "127.0.0.1:$port");
if ($sock) {
$sock->print("ok 11\n");
$sock->print("quit\n");
@@ -166,7 +167,10 @@ if($pid = fork()) {
# Then test UDP sockets
$server = IO::Socket->new(Domain => AF_INET,
Proto => 'udp',
- LocalAddr => 'localhost');
+ LocalAddr => 'localhost')
+ || IO::Socket->new(Domain => AF_INET,
+ Proto => 'udp',
+ LocalAddr => '127.0.0.1');
$port = $server->sockport;
if ($^O eq 'mpeix') {
@@ -179,7 +183,9 @@ if ($^O eq 'mpeix') {
} elsif (defined($pid)) {
#child
$sock = IO::Socket::INET->new(Proto => 'udp',
- PeerAddr => "localhost:$port");
+ PeerAddr => "localhost:$port")
+ || IO::Socket::INET->new(Proto => 'udp',
+ PeerAddr => "127.0.0.1:$port");
$sock->send("ok 12\n");
sleep(1);
$sock->send("ok 12\n"); # send another one to be sure
OpenPOWER on IntegriCloud