From the documentation of libevent:
Currently (as of Libevent 2.0.5-beta),
bufferevent_flush()
is only implemented for some bufferevent types. In particular, socket-based bufferevents don’t have it.
I tested the following code:
auto output = ::bufferevent_get_output(bev);
::evbuffer_add(output, "hello", 5);
// ::bufferevent_flush(bev, EV_WRITE, BEV_FLUSH);
Note that I commented out the last line ::bufferevent_flush(bev, EV_WRITE, BEV_FLUSH);
, but the data was still sent immediately.
Is bufferevent_flush
not necessary for a socket-based bufferevent in libevent? If so, how libevent decides when to send the pending data in evbuffer?