December 2000
Intermediate to advanced
784 pages
20h 54m
English
Naturally, IO::Socket provides support for UDP sockets. To create a socket suitable for outgoing messages, call IO::Socket::INET->new() with a Proto argument of " udp " and no other arguments:
my $sock = IO::Socket::INET->new (Proto=>'udp') or die $@;
To create a socket bound to a known local port or interface address, provide one or more of the LocalAddr and LocalPort arguments:
my $sock = IO::Socket::INET->new (Proto => 'udp',
LocalAddr => 12000,
LocalPort => 'localhost'
) or die $@;
You may also connect() the socket and set a default destination address for send() by providing new() with the PeerAddr and optionally PeerPort arguments:
my $sock = IO::Socket::INET->new (Proto =>'udp', PeerAddr=>'wuarchive.wustl.edu:daytime(17)' ...
Read now
Unlock full access