介绍:
https://www.yc00.com/web/1701464085a1090942.html
https://zhuanlan.zhihu.com/p/539621593?utm_id=0
https://blog.csdn.net/mafuli007/article/details/7476014
https://www.jianshu.com/p/23d1ce789dc9
https://blog.csdn.net/qq_35883464/article/details/103778404
https://www.cnblogs.com/dgqx/p/12619455.html
https://zhuanlan.zhihu.com/p/498735034
https://zhuanlan.zhihu.com/p/555406277
原理:https://zhuanlan.zhihu.com/p/370196778
https://www.yc00.com/web/1701464085a1090942.html
https://blog.csdn.net/myw31415926/article/details/127479054 (demo)

支持的事件类型

网络IO、定时器、信号
通过查看event.h文件,可以知道IO、定时器、信号事件函数都是对event_xx函数的封装。

1.定时器事件

https://codeantenna.com/a/hnit8y98Qx
与信号不同,evtimer_new 创建的事件是非持久化的,即默认情况下只会响应一次。

  • event_add (事件执行)
    时间参数不能为NULL,否则事件不会执行。

核心模块

1.buffevent (向服务端发起连接)

IO读写封装
https://zhuanlan.zhihu.com/p/245728240
https://blog.csdn.net/u014376961/article/details/89297119
https://www.dandelioncloud.cn/article/details/1529654856919040001
https://blog.csdn.net/u010710458/article/details/80067885 (buffevent demo)
https://blog.csdn.net/qq_44319972/article/details/130162708 (api介绍)
http://wed.xjx100.cn/news/182483.html (api介绍)
https://www.cnblogs.com/TechNomad/p/17878074.html (*)

  • bufferevent_set_timeouts
    设置指定bufferevent缓冲事件对象的读写超时时间。

  • bufferevent_get_input
    获取输入缓存,返回evbuffer对象

  • evbuffer_get_length
    获取缓存数据的长度

  • evbuffer_copyout
    从evbuffer拷贝数据出来

  • bufferevent_read
    从缓冲区读数据

  • bufferevent_write
    写到输出缓存

2.evconnlistener (监听客户端连接)

https://www.dandelioncloud.cn/article/details/1524310356382224386

3.EvBuffer (缓冲数据处理)

https://blog.csdn.net/qq_46312211/article/details/126015734

可移植性函数

https://www.cnblogs.com/uplooking/p/10982339.html

常见问题

Linux-X86

  • include fatal error: event.h: 没有那个文件或目录

    apt-get install libevent-dev


0 条评论

发表回复

您的电子邮箱地址不会被公开。