Have you looked in the perl documentation? Try looking in the perlipc manpage. There are some nice simple examples on writing IO::Socket clients and servers..
You basically want to write a server that listens to a certain port, and in each of your forked children, write an IO::Socket client which connects to that server. The server should probably also use IO::Select, which you can add a bunch of connections to, and deal with each one as and when it has data to be dealt with.
Eg: Assuming $sock1 and $sock2 are accepted client sockets on the server, and $server is the server socket:
my $sockets = IO::Select->new();
$sockets->add($server);
$sockets->add($sock1);
$sockets->add($sock2);
while(1)
{
my @handles = $sockets->can_read(3);
foreach my $handle (@handles)
{
if($handle == $server)
{
# Accept new client connection from server
}
elsif($handle == $sock1)
{
# Do something with info from $sock1
}
elsif ... # etc etc.
}
# last when whenever..
}
(Should probably keep the client sockets in an array though, easier to add/delete that way..)
Hope this makes any sense.. Post some code if you get stuck..
C. |