[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] What is the best way to detect a client socket disconnect?
On Tue, Nov 23, 2010 at 10:53 PM, Ken Feng <kfmfe04@xxxxxxxxx> wrote:
Within libevent, of course. As a point of reference, let's say we
start up the TCP Echo server that is in Nick's book here:
http://www.wangafu.net/~nickm/libevent-book/Ref8_listener.html
I could handle a normal client shutdown by sending a special shutdown
sequence from client to server, but what about connection lost? What
is the best way for the server to detect this state? Can I do it
without pinging the client?
Thanks in advance.
- Ken
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.
Are you using buffer events? If so, in your errorcb look for BEV_EVENT_EOF, BEV_EVENT_ERROR, and BEV_EVENT_TIMEOUT. Free the context pointer and call bufferevent_free().