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

[Libevent-users] Closing bufferevent



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