牵着老婆满街逛

严以律己,宽以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

libevent echo server example using buffered events

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

posted on 2007-08-21 01:29 杨粼波 阅读(471) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理