Commit | Line | Data |
37120919 |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib' if -d '../lib'; |
6 | require Config; import Config; |
c07a80fd |
7 | if ($Config{'extensions'} !~ /\bSocket\b/ && |
8 | !(($Config{'osname'} eq 'VMS') && $Config{d_has_socket})) { |
2af9ad4a |
9 | print "1..0\n"; |
37120919 |
10 | exit 0; |
11 | } |
12 | } |
13 | |
14 | use Socket; |
15 | |
16 | print "1..6\n"; |
17 | |
18 | if (socket(T,PF_INET,SOCK_STREAM,6)) { |
19 | print "ok 1\n"; |
20 | |
21 | if (connect(T,pack_sockaddr_in(7,inet_aton("localhost")))){ |
22 | print "ok 2\n"; |
23 | |
24 | print "# Connected to ", |
25 | inet_ntoa((unpack_sockaddr_in(getpeername(T)))[1]),"\n"; |
26 | |
27 | syswrite(T,"hello",5); |
28 | sysread(T,$buff,10); |
29 | print $buff eq "hello" ? "ok 3\n" : "not ok 3\n"; |
30 | } |
31 | else { |
32 | print "# You're allowed to fail tests 2 and 3 if.\n"; |
33 | print "# The echo service has been disabled.\n"; |
34 | print "# $!\n"; |
35 | print "ok 2\n"; |
36 | print "ok 3\n"; |
37 | } |
38 | } |
39 | else { |
40 | print "# $!\n"; |
41 | print "not ok 1\n"; |
42 | } |
43 | |
44 | if( socket(S,PF_INET,SOCK_STREAM,6) ){ |
45 | print "ok 4\n"; |
46 | |
47 | if (connect(S,pack_sockaddr_in(7,INADDR_LOOPBACK))){ |
48 | print "ok 5\n"; |
49 | |
50 | print "# Connected to ", |
51 | inet_ntoa((unpack_sockaddr_in(getpeername(S)))[1]),"\n"; |
52 | |
53 | syswrite(S,"olleh",5); |
54 | sysread(S,$buff,10); |
55 | print $buff eq "olleh" ? "ok 6\n" : "not ok 6\n"; |
56 | } |
57 | else { |
58 | print "# You're allowed to fail tests 5 and 6 if.\n"; |
59 | print "# The echo service has been disabled.\n"; |
60 | print "# $!\n"; |
61 | print "ok 5\n"; |
62 | print "ok 6\n"; |
63 | } |
64 | } |
65 | else { |
66 | print "# $!\n"; |
67 | print "not ok 4\n"; |
68 | } |