libevent编译与安装
libevent官网
Linux平台安装编译libevent
wget -c addr --no-check-certificate
./configure --prefix=/usr/local/libevent
make -j 8
make install
#include <event2/listener.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/thread.h>#include <arpa/inet.h>#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>static void
echo_read_cb(struct bufferevent *bev, void *ctx)
{/* 获取bufferevent中的读和写的指针 *//* This callback is invoked when there is data to read on bev. */struct evbuffer *input = bufferevent_get_input(bev);struct evbuffer *output = bufferevent_get_output(bev);/* 把读入的数据全部复制到写内存中 *//* Copy all the data from the input buffer to the output buffer. */evbuffer_add_buffer(output, input);
}static