[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] detection of TCP disconnection
Hello,
I am adding an event to a connected TCP server with the flags
EV_READ|EV_PERSIST and calling read() when i get a callback, in order to
get the data from the client.
In order to detect a "disconnection" by the client i look for a return
value of 0 from read() in the callback function.
This seems to work correctly when i do a kill -INT on the client or a kill
-9 on the client: the callback is triggered on the server and the return
from read() is 0.
However if i a do hard reset(power off) of the machine running the client,
it does not seem to work and I believe I am not getting a callback
function for the event on the server.
Is this the best way to detect the disconnection of a TCP client or is
there a smarter solution (other than using timeouts, which is a
possibility)?
Thanks!
Cheers,
Ivan Novick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.