amir has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: select() on a client and server socket
by bschmer (Friar) on Jul 11, 2001 at 16:18 UTC | |
by amir (Sexton) on Jul 11, 2001 at 20:49 UTC | |
|
Re: select() on a client and server socket
by bikeNomad (Priest) on Jul 11, 2001 at 17:42 UTC |