4 unless(grep /blib/, @INC) {
6 unshift @INC, '../lib' if -d '../lib';
13 if(-d "lib" && -f "TEST") {
16 if ($Config{'extensions'} !~ /\bSocket\b/) {
17 $reason = 'Socket was not built';
19 elsif ($Config{'extensions'} !~ /\bIO\b/) {
20 $reason = 'IO was not built';
22 elsif ($^O eq 'apollo') {
23 $reason = "unknown *FIXME*";
25 undef $reason if $^O eq 'VMS' and $Config{d_socket};
27 print "1..0 # Skip: $reason\n";
36 if (length($a) != length $b) {
37 my $min = (length($a) < length $b) ? length($a) : length $b;
38 if ($min and substr($a, 0, $min) eq substr($b, 0, $min)) {
39 printf "# Apparently: %d bytes junk at the end of %s\n# %s\n",
40 abs(length($a) - length ($b)),
41 $_[length($a) < length ($b) ? 1 : 0],
42 "consider decreasing bufsize of recfrom.";
43 substr($a, $min) = "";
44 substr($b, $min) = "";
48 my @a = unpack_sockaddr_in($a);
49 my @b = unpack_sockaddr_in($b);
50 "$a[0]$a[1]" eq "$b[0]$b[1]";
57 use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY);
59 # This can fail if localhost is undefined or the
60 # special 'loopback' address 127.0.0.1 is not configured
61 # on your system. (/etc/rc.config.d/netconfig on HP-UX.)
62 # As a shortcut (not recommended) you could change 'localhost'
63 # here to be the name of this machine eg 'myhost.mycompany.com'.
65 $udpa = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
66 or die "$! (maybe your system does not have the 'localhost' address defined)";
70 $udpb = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
71 or die "$! (maybe your system does not have the 'localhost' address defined)";
75 $udpa->send("ok 4\n",0,$udpb->sockname);
78 unless compare_addr($udpa->peername,$udpb->sockname, 'peername', 'sockname');
81 my $where = $udpb->recv($buf="",5);
86 unless(compare_addr($where,$udpa->sockname, 'recv name', 'sockname')) {
88 @xtra = (0,$udpa->sockname);
92 $udpb->send("ok 6\n",@xtra);
93 $udpa->recv($buf="",5);
96 print "not " if $udpa->connected;