from:
http://unx.ca/log/2006/08/31/libevent-echo-server-example-using-buffered-events/
This is another example of a libevent based echo server using the buffered event API provided by libevent. Buffered events provide an abstraction to reading and writing.
In the case of reading, libevent handles reading from the socket and presents your app with a buffer containing the read data. You can either work with the data available, or ignore it until more comes in.
The write abstraction is more useful, you can use the bufferevent functions to write to your socket without waiting for it to be write ready. libevent will handle the buffering until the socket is write ready and then write as much as the buffer as it can.
View example code: ibevent_echosrv_buffered.c
Download example code: libevent_buffered_ex-20060831.tar.gz
References:
* Unbuffered echo server example
* libevent