This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
dist/IO: Always bind to localhost in tests.
authorAli Polatel <alip@exherbo.org>
Sat, 16 Oct 2010 00:15:34 +0000 (17:15 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 16 Oct 2010 00:38:47 +0000 (17:38 -0700)
This is necessary on Exherbo, at least, because of the network
sandboxing that is done by 'sydbox'. And, in general, tests shouldn't be
listening on all interfaces.

dist/IO/t/io_multihomed.t
dist/IO/t/io_sock.t

index f1bd5b9..f2a8e11 100644 (file)
@@ -74,7 +74,8 @@ package main;
 
 use IO::Socket;
 
-$listen = IO::Socket::INET->new(Listen => 2,
+$listen = IO::Socket::INET->new(LocalAddr => 'localhost',
+                               Listen => 2,
                                Proto => 'tcp',
                                Timeout => 5,
                               ) or die "$!";
index 38aefee..9c964f0 100644 (file)
@@ -36,7 +36,8 @@ eval {
 
 use IO::Socket;
 
-$listen = IO::Socket::INET->new(Listen => 2,
+$listen = IO::Socket::INET->new(LocalAddr => 'localhost',
+                               Listen => 2,
                                Proto => 'tcp',
                                # some systems seem to need as much as 10,
                                # so be generous with the timeout
@@ -97,7 +98,7 @@ if($pid = fork()) {
 
 # Test various other ways to create INET sockets that should
 # also work.
-$listen = IO::Socket::INET->new(Listen => '', Timeout => 15) or die "$!";
+$listen = IO::Socket::INET->new(LocalAddr => 'localhost', Listen => '', Timeout => 15) or die "$!";
 $port = $listen->sockport;
 
 if($pid = fork()) {
@@ -224,7 +225,7 @@ if( !open( SRC, "< $0")) {
 ### TEST 16
 ### Start the server
 #
-my $listen = IO::Socket::INET->new( Listen => 2, Proto => 'tcp', Timeout => 15) ||
+my $listen = IO::Socket::INET->new(LocalAddr => 'localhost', Listen => 2, Proto => 'tcp', Timeout => 15) ||
     print "not ";
 print "ok 16\n";
 die if( !defined( $listen));