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";
37 if (length($a) != length $b) {
38 my $min = (length($a) < length $b) ? length($a) : length $b;
39 if ($min and substr($a, 0, $min) eq substr($b, 0, $min)) {
40 printf "# Apparently: %d bytes junk at the end of %s\n# %s\n",
41 abs(length($a) - length ($b)),
42 $_[length($a) < length ($b) ? 1 : 0],
43 "consider decreasing bufsize of recfrom.";
44 substr($a, $min) = "";
45 substr($b, $min) = "";
49 my @a = unpack_sockaddr_in($a);
50 my @b = unpack_sockaddr_in($b);
51 "$a[0]$a[1]" eq "$b[0]$b[1]";
58 use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY);
60 # This can fail if localhost is undefined or the
61 # special 'loopback' address 127.0.0.1 is not configured
62 # on your system. (/etc/rc.config.d/netconfig on HP-UX.)
63 # As a shortcut (not recommended) you could change 'localhost'
64 # here to be the name of this machine eg 'myhost.mycompany.com'.
66 $udpa = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
67 or die "$! (maybe your system does not have the 'localhost' address defined)";
71 $udpb = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
72 or die "$! (maybe your system does not have the 'localhost' address defined)";
76 $udpa->send("ok 4\n",0,$udpb->sockname);
79 unless compare_addr($udpa->peername,$udpb->sockname, 'peername', 'sockname');
82 my $where = $udpb->recv($buf="",5);
87 unless(compare_addr($where,$udpa->sockname, 'recv name', 'sockname')) {
89 @xtra = (0,$udpa->sockname);
93 $udpb->send("ok 6\n",@xtra);
94 $udpa->recv($buf="",5);
97 print "not " if $udpa->connected;