
Libevent
燕凌姣
以梦为马 不负韶华
展开
-
Libevent群:很值得体会的bufferevent+evconnlistener
//说明,为了使我们的代码兼容win32网络API,我们使用evutil_socket_t代替int,使用evutil_make_socket_nonblocking代替fcntl/* For sockaddr_in */#include /* For socket functions */#include /* For fcntl */#include #in原创 2014-06-25 10:45:17 · 821 阅读 · 0 评论 -
用libevent多线程方式实现echo server
功能:主线程同时监听定时器事件和IO事件,工作线程简单的监听IO事件。主线程每隔一秒种向工作线程发送一条字符串信息工作线程显示该信息并回显给主线程该示例演示了主线程如何同时监听多个事件。Makefileeventtest : eventtest.cgcc -Wall -g -levent -lpthread -o eventtest ev转载 2014-06-22 19:36:35 · 878 阅读 · 0 评论 -
libevent多线程使用事项
在linux平台上使用c开发网络程序的同志们一般情况下都对鼎鼎大名的libevent非常的熟悉了。但是一些新进入此领域的new new people们对此都是一头雾水。原本的迷茫再加上开源软件一贯的“帮助文件”缺失作风,让我们这些新手们显的非常的无助。幸好有一些热心的朋友们帮忙,才化险为夷啊! 前几天一直在开发一个locker server,虽然公司现有的locker server能转载 2014-06-22 20:27:35 · 1108 阅读 · 1 评论 -
libevent带负载均衡的多线程使用示例
分类: LINUX功能:主线程根据负载工作线程负载均衡算法,每隔一秒钟向特定的工作线程发送一条字符串信息,工作线程简单的把字符串信息打开出来。Makefileeventtest : eventtest.cgcc -Wall -g -levent -lpthread -o eventtest eventtest.c.PHONY : cleancle转载 2014-06-22 19:55:48 · 936 阅读 · 0 评论 -
Libevent示例程序4 信号量
shenhuayu@shenhuayu-VirtualBox ~/libevent $ gcc test.c -g -o mytest -leventshenhuayu@shenhuayu-VirtualBox ~/libevent $ ./mytest^Cgot signal.^Cgot signal.^Cgot signal.转载 2014-06-20 18:31:30 · 1204 阅读 · 0 评论 -
Libevent示例程序3 定时器程序
from http://blog.chinaunix.net/uid-25885064-id-3399135.html转载 2014-06-20 17:06:48 · 587 阅读 · 0 评论 -
Libevent示例程序2 socket程序
#include #include #include #include #include #include #include #include #include #include static short ListenPort = 8080; static long ListenAdd转载 2014-06-20 15:54:16 · 872 阅读 · 0 评论 -
Libevent示例程序7 bufferevent使用
/* * libevent echo server example using buffered events. */#include #include #include #include /* Required by event.h. */#include #include #include #include #include #include #include转载 2014-06-21 11:14:00 · 1233 阅读 · 0 评论 -
Libevent示例程序6 io事件
#include #include #include #include #include #include #include #include #include #include #include static void fifo_read(int fd, short event, void *arg){ char buf[255]; int len;转载 2014-06-21 10:49:29 · 928 阅读 · 0 评论 -
Libevent示例程序5 echo服务器
#include #include #include #include #include #include const int LISTEN_PORT = 9999;const int LISTEN_BACKLOG = 32; void do_accept(evutil_socket_t listener, short event, void *arg);void re转载 2014-06-21 10:17:42 · 778 阅读 · 0 评论 -
Libevent示例程序3 定时器程序续
shenhuayu@shenhuayu-VirtualBox ~/libevent $ gcc test.c -g -o mytest -leventshenhuayu@shenhuayu-VirtualBox ~/libevent $ ./mytesttimeout_cb called at 1403256637: 2.001 seconds elapsed.timeout_cb c转载 2014-06-20 17:31:50 · 543 阅读 · 0 评论 -
Libevent示例程序1
1、获取版本#include event.h>#include stdio.h>int main(){ const char *version = event_get_version(); printf("%s\n",version); return 0;}原创 2014-06-20 15:10:09 · 674 阅读 · 0 评论 -
Libevent基础
1,libevent是一个事件触发的网络库原创 2014-06-20 14:58:49 · 689 阅读 · 0 评论 -
Linux high performance:http请求的读取和分析
#include #include #include #include #include #include #include #include #include #include #define BUFFER_SIZE 4096enum CHECK_STATE { CHECK_STATE_REQUESTLINE = 0, CHECK_STATE_HEADER, CHECK_原创 2014-06-25 15:33:01 · 702 阅读 · 0 评论 -
Libevent群:很值得体会的多线程编程
/* This exmple program provides a trivial server program that listens for TCP connections on port 9995. When they arrive, it writes a short message to each client connection, and closes each co原创 2014-06-25 11:29:20 · 2270 阅读 · 0 评论 -
libevent源码浅析: http库
from 转自:http://godorz.info/author/godorz/page/3/libevent自带了一个http库,用它可以很简单的实现一个http服务器,本文非常简单地分析之.evhttpevhttp库有几个主要的结构体,它们之间的联系非常龌龊:其中,结构体event, min_heap, evsignal_info, e转载 2014-06-22 20:34:20 · 1378 阅读 · 0 评论