scmason has asked for the wisdom of the Perl Monks concerning the following question:
When we accept a new session, we can read and write to the socket through the <SESSION> filehandle. Like so:my $client = accept( SESSION, SOCK );
orwhile( $newmessage = <SESSION> ){ #do something }
Everything works great, except I am not sure how to detect a dropped connection when working with the filehandle that I got from accept().print SESSION "Here is your reply\n";
Once the client connects, the server starts processing some information and does not talk on the socket for a while. Sometimes the client decides they dont want to wait for results, so they disconnect. I would like to know when this happens so that I can stop processing the request. I dont mind checking it every couple of iterations, but I don't know the procedure.
I tried googling but nothing useful came back right away, so I am putting it in your hands!
Thanks
20050316 Edit by ysth: p and code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detecting Dead Socket Connection
by scmason (Monk) on Mar 17, 2005 at 00:09 UTC | |
by scmason (Monk) on Mar 17, 2005 at 23:44 UTC | |
by scmason (Monk) on Mar 17, 2005 at 23:33 UTC | |
by Tanktalus (Canon) on Mar 18, 2005 at 01:47 UTC | |
by scmason (Monk) on Mar 18, 2005 at 23:57 UTC | |
by Tanktalus (Canon) on Mar 19, 2005 at 00:26 UTC |