I am writing a server that listens on a socket and also connects to another server and sends/receives data on that socket. I want to be able to do this select() loop and have it handle both sockets, the server and the client. I connect $extsock to a client during a server request, so after I create a new Server object, that is when I connect to another server, and add that socket to select by doing:my $extsock = socket connected to some server... my @ready; while(@ready = $select->can_read) { my $socket; for $socket (@ready) { if($socket == $listen) { my $new_socket = $listen->accept; Server->new($new_socket, $select, \@clients); } else { my $client = $clients[$socket->fileno]; if(defined $client) { &{$client->nextsub}(); } else { # unknown data??? } } } }
How do I figure out if the "unknown data" is coming from $extsock? Since right now, when data comes in on the client socket, $client is not defined!?$main::extsock = new IO::Handle; $main::extsock = IO::Socket::INET->new(.......); $self->select->add($main::extsock);
Thanks a lot,
Amir
In reply to select() on a client and server socket by amir
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |