summaryrefslogtreecommitdiff
path: root/t/lib/io_udp.t
blob: 84e5067b852fb7b8471bc5cb37ce9ad0c5ab1219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!./perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib' if -d '../lib';
    require Config; import Config;
    if ( ($Config{'extensions'} !~ /\bSocket\b/ ||
          $Config{'extensions'} !~ /\bIO\b/)    &&
          !(($^O eq 'VMS') && $Config{d_socket})) {
	print "1..0\n";
	exit 0;
    }
}

$| = 1;
print "1..3\n";

use Socket;
use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY);

$udpa = IO::Socket::INET->new(Proto => 'udp', Addr => 'localhost');
$udpb = IO::Socket::INET->new(Proto => 'udp', Addr => 'localhost');

print "ok 1\n";

$udpa->send("ok 2\n",0,$udpb->sockname);
$rem = $udpb->recv($buf="",5);
print $buf;
$udpb->send("ok 3\n");
$udpa->recv($buf="",5);
print $buf;