4 unless(grep /blib/, @INC) {
6 @INC = '../lib' if -d '../lib';
13 if (-d "lib" && -f "TEST") {
14 if (!$Config{'d_fork'} ||
15 (($Config{'extensions'} !~ /\bSocket\b/ ||
16 $Config{'extensions'} !~ /\bIO\b/) &&
17 !(($^O eq 'VMS') && $Config{d_socket}))) {
29 $listen = IO::Socket::INET->new(Listen => 2,
36 # Check if can fork with dynamic extensions (bug in CRT):
38 system "$^X -I../lib -MOpcode -e 'defined fork or die' > /dev/null 2>&1") {
39 print "ok $_ # skipped: broken fork\n" for 2..5;
43 $port = $listen->sockport;
47 $sock = $listen->accept();
51 print $sock->getline();
61 } elsif(defined $pid) {
63 # This can fail if localhost is undefined or the
64 # special 'loopback' address 127.0.0.1 is not configured
65 # on your system. (/etc/rc.config.d/netconfig on HP-UX.)
66 # As a shortcut (not recommended) you could change 'localhost'
67 # here to be the name of this machine eg 'myhost.mycompany.com'.
69 $sock = IO::Socket::INET->new(PeerPort => $port,
71 PeerAddr => 'localhost'
73 or die "$! (maybe your system does not have the 'localhost' address defined)";
79 print $sock->getline();
88 # Test various other ways to create INET sockets that should
90 $listen = IO::Socket::INET->new(Listen => '', Timeout => 2) or die "$!";
91 $port = $listen->sockport;
96 last SERVER_LOOP unless $sock = $listen->accept;
98 last SERVER_LOOP if /^quit/;
105 } elsif (defined $pid) {
106 # child, try various ways to connect
107 $sock = IO::Socket::INET->new("localhost:$port");
109 print "not " unless $sock->connected;
111 $sock->print("ok 7\n");
114 $sock->print("ok 9\n");
115 $sock->print("done\n");
126 # some machines seem to suffer from a race condition here
129 $sock = IO::Socket::INET->new("127.0.0.1:$port");
131 $sock->print("ok 10\n");
132 $sock->print("done\n");
140 # some machines seem to suffer from a race condition here
143 $sock = IO::Socket->new(Domain => AF_INET,
144 PeerAddr => "localhost:$port");
146 $sock->print("ok 11\n");
147 $sock->print("quit\n");
156 # Then test UDP sockets
157 $server = IO::Socket->new(Domain => AF_INET,
159 LocalAddr => 'localhost');
160 $port = $server->sockport;
164 $server->recv($buf, 100);
166 } elsif (defined($pid)) {
168 $sock = IO::Socket::INET->new(Proto => 'udp',
169 PeerAddr => "localhost:$port");
170 $sock->send("ok 12\n");
172 $sock->send("ok 12\n"); # send another one to be sure
178 print "not " unless $server->blocking;
181 $server->blocking(0);
182 print "not " if $server->blocking;