[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Q: Exception callbacks and events that should run immediately



On Wed, Dec 5, 2012 at 10:54 AM, Sashan Govender <sashang@xxxxxxxxx> wrote:
Hi!
 
1) I don't see any notion of event notification on FD exception - e.g. socket close.
    There are some words for buffer events, but nothing for regular file
    descriptor based callbacks. So what is a good way to get a callback when specific
    FD is closed/disconnected?
 
If the fd is a socket and the peer closes then you'll get a read callback. When you read from the fd 'read' will return 0 indicating that the peer closed.

But if the peer die without closing the socket, you will never get a read event. In this case you will fail when writing to the socket.

You can simulate this by disconnecting the peer from the network.