HansB has asked for the wisdom of the Perl Monks concerning the following question:
I have a simple server using IO::Socket, which is supposed to send one directional data to a client when they connect.
It looks like something like this...
I did some debugging and it seems to die on the "print $client <IN>" line, so I added "$client->connected", and that helped the issue a little. The server now dies only on the 3rd or 4th time a client disconnects. There are no errors or warnings thrown.while ( my $client = $server->accept() ) { open( IN, "/usr/bin/someprogram |" ); while ( <IN> ) { if ( $client->connected ) { print $client <IN>; } } }
The server sends data fairly rapidly, so I suspect that if the connection is closed after the "$client->connected" is performed but before the print command, it dies?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: program dies when printing to closed socket, I think
by jbert (Priest) on Aug 16, 2007 at 16:16 UTC | |
by HansB (Initiate) on Aug 16, 2007 at 16:51 UTC | |
|
Re: program dies when printing to closed socket, I think
by almut (Canon) on Aug 16, 2007 at 16:02 UTC | |
by HansB (Initiate) on Aug 16, 2007 at 16:15 UTC |