On Fri, Mar 3, 2017 at 8:20 AM, prashantkumar dhotre
<[email protected]> wrote:
> Hi
> server machine went unreachable and tcp connnection to server remained
> 'established'.
> in this scenario, i see that bufferevent_write still succeeds.
> It should fail. right ?
Hi,
No, bufferevent_write() will add passed buffer to internal one, and
once bufferevent will be ready to accept data it will send it to it.
> if this is expected behavior , then how do i detect a dead tcp connection ?
You should check for BEV_EVENT_EOF/BEV_EVENT_ERROR in eventcb:
static void
eventcb(struct bufferevent *bev, short events, void *user_data)
{
if (events & BEV_EVENT_EOF) {
printf("Connection closed.\n");
} else if (events & BEV_EVENT_ERROR) {
printf("Got an error on the connection: %s\n", strerror(errno));
}
bufferevent_free(bev);
}
bufferevent_setcb(bev, readcb, writecb, eventcb, NULL);
***********************************************************************
To unsubscribe, send an e-mail to [email protected] with
unsubscribe libevent-users in the body.