This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add tests for new IO extension
[perl5.git] / t / lib / io_udp.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib' if -d '../lib';
6     require Config; import Config;
7     if ( ($Config{'extensions'} !~ /\bSocket\b/ ||
8           $Config{'extensions'} !~ /\bIO\b/)    &&
9           !(($^O eq 'VMS') && $Config{d_socket})) {
10         print "1..0\n";
11         exit 0;
12     }
13 }
14
15 $| = 1;
16 print "1..3\n";
17
18 use Socket;
19 use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY);
20
21 $udpa = IO::Socket::INET->new(Proto => 'udp', Addr => 'localhost');
22 $udpb = IO::Socket::INET->new(Proto => 'udp', Addr => 'localhost');
23
24 print "ok 1\n";
25
26 $udpa->send("ok 2\n",0,$udpb->sockname);
27 $rem = $udpb->recv($buf="",5);
28 print $buf;
29 $udpb->send("ok 3\n");
30 $udpa->recv($buf="",5);
31 print $buf;