} 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);
$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";
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");
# 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') {
} 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