use strict;
use IO::Socket;
use IO::Select;
#set up some handles
my $h1 = IO::Socket::INET->( LocalPort => $port_1,
Proto => 'udp'
) or die "Couldn't start upd listen on $port_1: $@\n";
my $h2 = IO::Socket::INET->( LocalPort => $port_2,
Proto => 'udp'
) or die "Couldn't start upd listen on $port_2: $@\n";
my $readable_h = new IO::Select();
$readable_h->add($h1);
$readable_h->add($h2);
while (1) {
my @readable = $readable_h->can_read($timeout);
foreach my $sock (@readable) {
$buf = <$sock>
#
## do something with buf
#
}
}
Coded quickly mising detail but should give you the right idea.
mitd-Made in the Dark
'My favourite colour appears to be grey.' |