[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Closing bufferevent
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] Closing bufferevent
- From: Zac Sims <zac.sims@xxxxxxxxx>
- Date: Tue, 2 Mar 2010 22:54:55 +1100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 02 Mar 2010 06:55:05 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=s49BA7BCgsBzR6g85XanR8+Pk+tMJT0kcDdT6VGEZ8Y=; b=O9h4mxm+rHY1v95tijhJXsXOmaSasg2tdME/+sW2DEJEEV2DVT+ysAz4BnQgmQPECD lGByz9VpX5c2q8ItlMN/HlwqTWRlrJ6UF5tA+neGJBRZBdzE9FntQWTVWNZOzBYZc1st 7KOVEERNzNiiEc9XoPv+hXRBmNkm5YGzc1atA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=tQHU4KHyPEMQtjJENoiHeSVFW4hS6D3tXzEhrtqllPt6rCxi7w2xJBR2BB7PTUVpd4 OS1vc4rzeMloP7FT9MWj8SHLnce/Xl1zZlGd8oAyTMY7pfKLpn9GaTDctX8j0L6ZMw15 FPA7CG4szuM//KxFA7jmRzQjGs3m8IFZFOb9E=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
G'day,
Perhaps I'm missing something, but what's the proper way to force a bufferevent closed? That is, get a BEV_EVENT_EOF or similar event with the registered event call-back once it's closed.
bufferevent_setcb(bev, readcb, NULL, eventcb, NULL);
bufferevent_enable(bev, EV_READ | EV_WRITE);
void con_readcb(struct bufferevent * bev, void * arg)
{
...
fd = bufferevent_getfd();
...
EVUTIL_CLOSESOCKET(fd);
}
void eventcb(struct bufferevent * bev, short events, void * arg)
{
... event never comes ...
bufferevent_free(bev);
}
I've tried closing the socket myself once I have the fd (using bufferevent_getfd()). But that
doesn't seem to generate an event on the registered eventcb.
Could I set a timeout for 0 seconds in order to get the eventcb to fire? That way I could use
BEV_OPT_CLOSE_ON_FREE. Of course, that runs with the problem of more data arriving.
Thanks
Zac