It would be good if we had a nice way to send shutdowns() and/or DisconnectEx calls to sockets on a bufferevent. Here are some ideas from http://archives.seul.org/libevent/users/Oct-2010/msg00068.html .
"Yes, what kind of API did you have in mind? The easiest would be
something to implement bufferevent_flush(BEV_FINSISHED) for sockets,
and define it to a) write as much as possible, and b) if all data is
written, shutdown() the socket.
But it seems that what people usually want instead is something that
will start writing, wait till all data is written, then shutdown() the
socket. I'm a little less thrilled with writing one of these, since
it's just a wrapper around other functionality, but it does seem to be
the kind of thing that people. It should probably be called something
like ... well, bufferevent_flush() is taken.
bufferevent_flush_and_shutdown(), maybe ? It should call the event
callback with a new event type, BEV_SENT_CLOSE, when it's finished.
It should also respect write timeouts.
Does anybody care strongly about this to try writing the code and tests?"