in reply to UDP server

Stolen from Perl Cookbook, Chapter 17

Problem

You want to write a UDP server.

Solution

First bind to the port the server is to be contacted on. With IO::Socket, this is easily accomplished:
use IO::Socket; $server = IO::Socket::INET->new(LocalPort => $server_port, Proto => "udp") or die "Couldn't be a udp server on port $server_port : $@\n";
Then, go into a loop receiving messages:
while ($him = $server->recv($datagram, $MAX_TO_READ, $flags)) { # do something }
I haven't written anything that runs as a UDP server. It's all been TCP with what I've done. This may help. I'd recommend taking a look at this whole chapter, if you can.

--Chris

e-mail jcwren

Replies are listed 'Best First'.
RE: RE: UDP server
by tiny (Beadle) on Jul 11, 2000 at 21:35 UTC
    Awesome! Thanks a lot, that did exactly what I needed it to do. /me runs out to purchase Perl Cookbook.