Implement $^C to allow perl access to -c flag - I think this
[p5sagit/p5-mst-13.2.git] / t / lib / io_udp.t
CommitLineData
61f2b451 1#!./perl
2
3BEGIN {
7a4c00b4 4 unless(grep /blib/, @INC) {
5 chdir 't' if -d 't';
6 @INC = '../lib' if -d '../lib';
7 }
8}
9
10use Config;
11
12BEGIN {
13 if(-d "lib" && -f "TEST") {
14 if ( ($Config{'extensions'} !~ /\bSocket\b/ ||
15 $Config{'extensions'} !~ /\bIO\b/ ||
16 $^O eq 'os2') &&
17 !(($^O eq 'VMS') && $Config{d_socket})) {
18 print "1..0\n";
19 exit 0;
20 }
61f2b451 21 }
22}
23
24$| = 1;
25print "1..3\n";
26
27use Socket;
28use IO::Socket qw(AF_INET SOCK_DGRAM INADDR_ANY);
29
68820cec 30 # This can fail if localhost is undefined or the
31 # special 'loopback' address 127.0.0.1 is not configured
32 # on your system. (/etc/rc.config.d/netconfig on HP-UX.)
9b599b2a 33 # As a shortcut (not recommended) you could change 'localhost'
34 # here to be the name of this machine eg 'myhost.mycompany.com'.
68820cec 35
9b599b2a 36$udpa = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
37 or die "$! (maybe your system does not have the 'localhost' address defined)";
38$udpb = IO::Socket::INET->new(Proto => 'udp', LocalAddr => 'localhost')
39 or die "$! (maybe your system does not have the 'localhost' address defined)";
61f2b451 40
41print "ok 1\n";
42
43$udpa->send("ok 2\n",0,$udpb->sockname);
7a4c00b4 44$udpb->recv($buf="",5);
61f2b451 45print $buf;
46$udpb->send("ok 3\n");
47$udpa->recv($buf="",5);
48print $buf;