Commit | Line | Data |
---|---|---|
61f2b451 | 1 | #!./perl |
2 | ||
3 | BEGIN { | |
7a4c00b4 | 4 | unless(grep /blib/, @INC) { |
5 | chdir 't' if -d 't'; | |
6 | @INC = '../lib' if -d '../lib'; | |
7 | } | |
8 | } | |
9 | ||
10 | use Config; | |
11 | ||
12 | BEGIN { | |
774d564b | 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}))) { | |
7a4c00b4 | 18 | print "1..0\n"; |
19 | exit 0; | |
20 | } | |
61f2b451 | 21 | } |
22 | } | |
23 | ||
24 | $| = 1; | |
25 | print "1..5\n"; | |
26 | ||
27 | use IO::Socket; | |
28 | ||
7a4c00b4 | 29 | $listen = IO::Socket::INET->new(Listen => 2, |
30 | Proto => 'tcp', | |
31 | ) or die "$!"; | |
61f2b451 | 32 | |
7a4c00b4 | 33 | print "ok 1\n"; |
61f2b451 | 34 | |
a245ea2d | 35 | # Check if can fork with dynamic extensions (bug in CRT): |
36 | if ($^O eq 'os2' and | |
37 | system "$^X -I../lib -MOpcode -e 'defined fork or die' > /dev/null 2>&1") { | |
38 | print "ok $_ # skipped: broken fork\n" for 2..5; | |
39 | exit 0; | |
40 | } | |
41 | ||
7a4c00b4 | 42 | $port = $listen->sockport; |
61f2b451 | 43 | |
7a4c00b4 | 44 | if($pid = fork()) { |
61f2b451 | 45 | |
46 | $sock = $listen->accept(); | |
47 | print "ok 2\n"; | |
48 | ||
49 | $sock->autoflush(1); | |
50 | print $sock->getline(); | |
51 | ||
52 | print $sock "ok 4\n"; | |
53 | ||
54 | $sock->close; | |
55 | ||
56 | waitpid($pid,0); | |
57 | ||
58 | print "ok 5\n"; | |
61f2b451 | 59 | |
7a4c00b4 | 60 | } elsif(defined $pid) { |
61f2b451 | 61 | |
68820cec | 62 | # This can fail if localhost is undefined or the |
63 | # special 'loopback' address 127.0.0.1 is not configured | |
64 | # on your system. (/etc/rc.config.d/netconfig on HP-UX.) | |
9b599b2a | 65 | # As a shortcut (not recommended) you could change 'localhost' |
66 | # here to be the name of this machine eg 'myhost.mycompany.com'. | |
68820cec | 67 | |
61f2b451 | 68 | $sock = IO::Socket::INET->new(PeerPort => $port, |
69 | Proto => 'tcp', | |
70 | PeerAddr => 'localhost' | |
9b599b2a | 71 | ) |
72 | or die "$! (maybe your system does not have the 'localhost' address defined)"; | |
61f2b451 | 73 | |
74 | $sock->autoflush(1); | |
7a4c00b4 | 75 | |
61f2b451 | 76 | print $sock "ok 3\n"; |
7a4c00b4 | 77 | |
61f2b451 | 78 | print $sock->getline(); |
7a4c00b4 | 79 | |
61f2b451 | 80 | $sock->close; |
7a4c00b4 | 81 | |
61f2b451 | 82 | exit; |
83 | } else { | |
84 | die; | |
85 | } | |
86 | ||
87 | ||
88 | ||
89 | ||
90 | ||
91 |