LibEvent
Phoenix_FuliMa
这个作者很懒,什么都没留下…
展开
-
libevent简单介绍
1 简介主页:http://www.monkey.org/~provos/libevent/。 libevent是一个事件触发的网络库,适用于windows、linux、bsd等多种平台,内部使用select、epoll、kqueue等系统调用管理事件机制。 编译库代码,编译脚本会判断OS支持哪种类型的事件机制(select、epoll或kqueue),然后条件编译相转载 2012-04-19 08:44:38 · 21082 阅读 · 0 评论 -
libevent简单应用_2
目的:测试event_base_loop()函数 方法: 作为服务器端,当有数据到来的时候,立刻关闭base*/#include #include #include #include #include #include void cb(evutil_socket_t sock, short what, void *arg){ printf("function cb is c原创 2012-10-19 18:37:46 · 1078 阅读 · 0 评论 -
libevent简单应用_1_时间定时器
#include #include #include #include #include #include using namespace std;struct EventTimerParam{ struct timeval tv; void *ctx; void *evt;}; void libevent_tick_event_cb(evutil_socket_t原创 2012-10-19 17:09:47 · 3190 阅读 · 0 评论 -
libevent简单应用_4
#include #include #include #include #include #include #include #include /* 设置计数,只允许echo_write_cb调用一次 */static int count = 1;/*当有数据可读的时候,会调用这个函数 */static void echo_read_cb(struct bufferev原创 2012-10-20 10:38:22 · 2233 阅读 · 1 评论 -
libevent源码深度剖析
ibevent源码深度剖析Posted on November 15, 20111 前言Libevent是一个轻量级的开源高性能网络库,使用者众多,研究者更甚,相关文章也不少。写这一系列文章的用意在于,一则分享心得;二则对libevent代码和设计思想做系统的、更深层次的分析,写出来,也可供后来者参考。附带一句:Libevent是用c语言编写的(MS大牛们都转载 2012-08-01 08:50:56 · 7879 阅读 · 2 评论 -
Windows下编译libevent
切换到"libevent-2.0.10-stable/" 目录下,在VS命令行下执行nmake /f Makefile.nmake。即可生成我们需要的libevent_core.lib libevent_extras.lib libevent.lib 3个静态库文件。原创 2012-04-12 22:59:13 · 1637 阅读 · 0 评论 -
LIBEVENT应用举例1
#include #include #include #include #include #include #include #include #include void sock_read(int fd, short event, void *arg){ char buf[255] = {0}; int len; struct event * ev = (stru转载 2012-05-09 14:08:36 · 791 阅读 · 0 评论 -
LIBEVENT应用举例2
#include #include #include #include #include #include #include #include #define PORT 25341#define BACKLOG 5#define MEM_SIZE 1024struct event_base* base;struct sock_ev { st转载 2012-05-09 14:09:26 · 999 阅读 · 0 评论 -
libevent杂谈
libevent是一个优秀的跨平台异步事件驱动库.当然,使用libevent的所有主品中,最有代表性的就是Memcached了.本文主要讲是libevent的在应用上的一些基础知识,大湿们莫笑.最简情形最简单的libevent示例在libevent官方首页可下载.地址:http://www.monkey.org/~provos/libevent/event-test.c本示例中转载 2012-05-09 14:06:09 · 2466 阅读 · 0 评论 -
socket异步编程--libevent的使用
这篇文章介绍下libevent在socket异步编程中的应用。在一些对性能要求较高的网络应用程序中,为了防止程序阻塞在socket I/O操作上造成程序性能的下降,需要使用异步编程,即程序准备好读写的函数(或接口)并向系统注册,然后在需要的时候只向系统提交读写的请求之后就继续做自己的事情,实际的读写操作由系统在合适的时候调用我们程序注册的接口进行。异步编程会给一些程序猿带来一些理解和编写上的困难,转载 2012-05-08 15:04:11 · 1033 阅读 · 0 评论 -
libevent简单应用_3(来自源码)
//利用bufferevent_socket_connect()建立网络连接#include #include #include #include void eventcb(struct bufferevent *bev, short events, void *ptr){ if (events & BEV_EVENT_CONNECTED) { /* We原创 2012-10-19 20:20:19 · 2099 阅读 · 0 评论