in reply to Re: Two-Part Socket Question.
in thread Two-Part Socket Question.
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.
|
|---|