Welcome to the Monastery | |
PerlMonks |
How to set a timeout for the socket filehandle generated by POE::Wheel::SocketFactory ?by sunshine_august (Scribe) |
on Dec 30, 2008 at 04:07 UTC ( [id://733168]=perlquestion: print w/replies, xml ) | Need Help?? |
sunshine_august has asked for the wisdom of the Perl Monks concerning the following question:
Hi, all monks: I am building tcp client/server based on POE::Wheel::SocketFactory and POE::Wheel::ReadWrite, and I want the server side can detect the event that the client side is disconnected from the internet as soon as possible(like someone pull the wire out, or the wire is loose, but the client side is still alive, so no tcp FIN package is sent to the server ). Originally, I think I can set a timeout for the connection accepted by POE::Wheel::SocketFactory, So I use 'sockopt' against the client socket generated by the SocketFactory like the code below. onWheelSFSuccess() is the handler of 'SuccessEvent' event in POE::Wheel::SocketFactory : but, I got the following error complainted:
So, I know, the 'clientSocket' is no longer a socket filehande but just a filehandle, it has lost its socket attributes. But how can I set a time out for this 'clientSocket', so I can let the POE::Wheel::ReadWrite trigger an ErrorEvent if it can't send the message out within the timeout? Or, Is there a better and more convinent way to detect the disconnection of the client side in POE?
Back to
Seekers of Perl Wisdom
|
|