5 unshift @INC, '../lib' if -d '../lib';
6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bSocket\b/ &&
8 !(($^O eq 'VMS') && $Config{d_socket})) {
18 if (socket(T,PF_INET,SOCK_STREAM,6)) {
21 if (connect(T,pack_sockaddr_in(7,inet_aton("localhost")))){
24 print "# Connected to ",
25 inet_ntoa((unpack_sockaddr_in(getpeername(T)))[1]),"\n";
27 syswrite(T,"hello",5);
28 $read = sysread(T,$buff,10); # Connection may be granted, then closed!
29 while ($read > 0 && length($buff) < 5) {
30 # adjust for fact that TCP doesn't guarantee size of reads/writes
31 $read = sysread(T,$buff,10,length($buff));
33 print(($read == 0 || $buff eq "hello") ? "ok 3\n" : "not ok 3\n");
36 print "# You're allowed to fail tests 2 and 3 if.\n";
37 print "# The echo service has been disabled.\n";
48 if( socket(S,PF_INET,SOCK_STREAM,6) ){
51 if (connect(S,pack_sockaddr_in(7,INADDR_LOOPBACK))){
54 print "# Connected to ",
55 inet_ntoa((unpack_sockaddr_in(getpeername(S)))[1]),"\n";
57 syswrite(S,"olleh",5);
58 $read = sysread(S,$buff,10); # Connection may be granted, then closed!
59 while ($read > 0 && length($buff) < 5) {
60 # adjust for fact that TCP doesn't guarantee size of reads/writes
61 $read = sysread(S,$buff,10,length($buff));
63 print(($read == 0 || $buff eq "olleh") ? "ok 6\n" : "not ok 6\n");
66 print "# You're allowed to fail tests 5 and 6 if.\n";
67 print "# The echo service has been disabled.\n";