in reply to Re: Two-Part Socket Question.
in thread Two-Part Socket Question.

"I say this makes since because when the first connection comes in the second, third and foruth do not exist yet so the forked process has no way of knowing abou them, Same with the second, third, fourth and so-on. How can I logically setup this code to keep an updated list of socket conenction on all forked children? "

It gets pretty hard to do this in a forking server model. I use the Net::EasyTCP module for this, but it dosn't use a forked model. The basic idea is to save your client objects in a hash, like this PSEUDOCODE:

my $new; my $counter = 0; my %clients; if($obj == $sock) { # Create a new socket $new = $sock->accept; $sel->add($new); $counter++ $clients{$counter}{'obj'} = $obj; $clients{$counter}{'ip'} = $obj->remoteip; #or whatever identifiers you can get

Now you have to figure out how to get that hash data to all your forked processes. You can either you pipes or sockets for the interprocess communication. It's more complicated than I can code of the top of my head.

The other option is to use a threaded server model, which has been done nicely at this node: Re: Re: ChatServer

In threads, you can use the cond_broadcast to communicate between threads.


I'm not really a human, but I play one on earth. flash japh