woutvc has asked for the wisdom of the Perl Monks concerning the following question:

I have a server program and a client is connecting to it. This is the code:
while(1) { &write_log(\*LOG,$program,"Waiting for client to connect..."); while($client = $server->accept()) { $client->autoflush(1); while (<$client>) { chomp; $buffer=substr($_,0,66); # Perform actions with the buffer and get the answer print $client "$answer\n"; &write_log(\*LOG,$program,"SERV -> CLNT <$answer>"); &ora_commit($dbh); } &write_log(\*LOG,$program,"Waiting for client to connect..."); close $client; } &write_log(\*LOG,$program,"Waiting for counter $counter"); $counter = $counter+1; }
This works fine until, the client disconnects unexpectedly. Then I'm stuck in the while (<client>) loop. Is there anyway to get the client connection closed when he unexpectedly disconnects. The script runs on a HP-UX machine. Perhaps I can use some UNIX command to check this?

Replies are listed 'Best First'.
Re: Socket checking client availability
by SuicideJunkie (Vicar) on Nov 12, 2008 at 15:16 UTC