Marcello has asked for the wisdom of the Perl Monks concerning the following question:
When I connect as a client, the forked process starts logging the status of the client socket. The problem is that when I disconnect the client, the state of the client socket is not changed and the forked process never stops. The logfile contains the following lines:if ($self->Bind()) { while ($self->ClientSocket($self->Accept())) { $self->ClientSocket->autoflush(1); my $pid; if (!defined($pid = fork())) { $self->LogError("Fork failed: ".$!); } # Child process elsif ($pid == 0) { while ($self->ClientSocket->connected) { $self->LogComment("[".$self->ClientSocket->opened."][" +.defined($self->ClientSocket->connected)."][".defined($self->ClientSo +cket)."]"); sleep(5); } # Close the socket connection when the client goes away close($self->ClientSocket); exit 0; } # Parent process else { # Close the socket with the client close($self->ClientSocket); } } }
How do I check in the forked process that the client socket is no longer valid? And why are the opened/connected calls returning true when the client already disconnected?[1][1][1] [1][1][1] [1][1][1] [1][1][1] etc...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Socket problem
by castaway (Parson) on Jan 30, 2003 at 12:41 UTC | |
by Marcello (Hermit) on Jan 30, 2003 at 12:50 UTC | |
by castaway (Parson) on Jan 30, 2003 at 21:36 UTC | |
|
Re: Socket problem
by Helter (Chaplain) on Jan 30, 2003 at 14:35 UTC | |
|
Re: Socket problem
by pg (Canon) on Jan 31, 2003 at 04:36 UTC |