代码改变世界

随笔分类 -  libevent

分享一个libevent server——cliserver

2013-03-17 12:05 by java20130722, 362 阅读, 收藏,
摘要: /* * An event-driven server that handles simple commands from multiple clients. * If no command is received for 60 seconds, the client will be disconnected. * * Note that evbuffer_readline() is a potential source of denial of service, as * it does an O(n) scan for a newline character each time ... 阅读全文

Connection listeners: accepting TCP connections 翻译

2013-03-15 22:35 by java20130722, 468 阅读, 收藏,
摘要: 连接监听器:接收TCP连接evconnlistener机制给我们提供一种监听和接收TCP连接的方法。在本节中所有的函数和类型都声明在头文件里。除非其他地方提到,否则这些在libevent-2.02-alpha首次给出。创建和释放 一个evconnlistener接口struct evconnlistener *evconnlistener_new(struct event_base *base, evconnlistener_cb cb, void *ptr, unsigned flags, int backlog, evutil_socket_t fd); struct ev... 阅读全文