in reply to Client still valid?
In general, you can wrap the part of the program that's crashing in an eval block, then catch the errors instead of crashing:
eval { $client->send() if $client; }; if ($@) { handle-error }
Solutions that involve checking whether the client is still connected are better, but still involve race conditions. There are two seperate steps---checking if they're connected, then sending the data---and if the client disconnects between those two steps the check won't have done any good. It won't happen very often, but it can happen, and it will when the server has been used enough times in the Real World.
Also, it's strange that a failed $client->send() would cause your script to crash instead of simply returning an error status. What error message does it exit with?
|
|---|