This is my patch patch.1n for perl5.001.
[p5sagit/p5-mst-13.2.git] / t / lib / socket.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require Config; import Config;
7     if ($Config{'extensions'} !~ /\bSocket\b/ && $Config{'osname'} ne 'VMS') {
8         print STDERR "1..0\n";
9         exit 0;
10     }
11 }
12         
13 use Socket;
14
15 print "1..6\n";
16
17 if( socket(T,PF_INET,SOCK_STREAM,6) ){
18   print "ok 1\n";
19
20   if( connect(T,pack_sockaddr_in(AF_INET,7,inet_aton("localhost")))){
21         print "ok 2\n";
22
23         print "# Connected to ",
24                 inet_ntoa((unpack_sockaddr_in(getpeername(T)))[2]),"\n";
25
26         syswrite(T,"hello",5);
27         sysread(T,$buff,10);
28         print $buff eq "hello" ? "ok 3\n" : "not ok 3\n";
29   }
30   else{
31         print "# $!\n";
32         print "not ok 2\n";
33   }
34 }
35 else{
36         print "# $!\n";
37         print "not ok 1\n";
38 }
39
40 if( socket(S,PF_INET,SOCK_STREAM,6) ){
41   print "ok 4\n";
42
43   if( connect(S,pack_sockaddr_in(AF_INET,7,INADDR_LOOPBACK))){
44         print "ok 5\n";
45
46         print "# Connected to ",
47                 inet_ntoa((unpack_sockaddr_in(getpeername(S)))[2]),"\n";
48
49         syswrite(S,"olleh",5);
50         sysread(S,$buff,10);
51         print $buff eq "olleh" ? "ok 6\n" : "not ok 6\n";
52   }
53   else{
54         print "# $!\n";
55         print "not ok 5\n";
56   }
57 }
58 else{
59         print "# $!\n";
60         print "not ok 4\n";
61 }
62