4 unless(grep /blib/, @INC) {
9 require($ENV{PERL_CORE} ? './test.pl' : './t/test.pl');
13 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) {
14 $reason = 'Socket was not built';
16 elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) {
17 $reason = 'IO was not built';
19 elsif ($^O eq 'apollo') {
20 $reason = "unknown *FIXME*";
22 undef $reason if $^O eq 'VMS' and $Config{d_socket};
23 skip_all($reason) if $reason;
30 if (length($a) != length $b) {
31 my $min = (length($a) < length $b) ? length($a) : length $b;
32 if ($min and substr($a, 0, $min) eq substr($b, 0, $min)) {
33 printf "# Apparently: %d bytes junk at the end of %s\n# %s\n",
34 abs(length($a) - length ($b)),
35 $_[length($a) < length ($b) ? 1 : 0],
36 "consider decreasing bufsize of recfrom.";
37 substr($a, $min) = "";
38 substr($b, $min) = "";
42 my @a = unpack_sockaddr_in($a);
43 my @b = unpack_sockaddr_in($b);
44 "$a[0]$a[1]" eq "$b[0]$b[1]";
51 use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY);
53 $udpa = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
54 || IO::Socket::INET->new(Proto => 'udp', LocalAddr => '127.0.0.1')
55 or die "$! (maybe your system does not have a localhost at all, 'localhost' or 127.0.0.1)";
58 $udpb = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
59 || IO::Socket::INET->new(Proto => 'udp', LocalAddr => '127.0.0.1')
60 or die "$! (maybe your system does not have a localhost at all, 'localhost' or 127.0.0.1)";
63 $udpa->send('BORK', 0, $udpb->sockname);
65 ok(compare_addr($udpa->peername,$udpb->sockname, 'peername', 'sockname'));
67 my $where = $udpb->recv($buf="", 4);
72 if (! ok(compare_addr($where,$udpa->sockname, 'recv name', 'sockname'))) {
73 @xtra = (0, $udpa->sockname);
76 $udpb->send('FOObar', @xtra);
77 $udpa->recv($buf="", 6);
80 ok(! $udpa->connected);