Epoll触发事件的类型(转载)
2016-11-27 14:40
225 查看
很Amazing,客服端关闭(close)居然不是触发epoll的EPOLLHUP事件,结果找了老半天的错误,记录一下。为此警惕自己,不能相信直觉,一切从文档出发。
以下内容均为转载(后面给出了原文的连接)
1、listen fd,有新连接请求,触发EPOLLIN。
2、对端发送普通数据,触发EPOLLIN。
3、带外数据,只触发EPOLLPRI。
4、对端正常关闭(程序里close(),shell下kill或ctr+c),触发EPOLLIN和EPOLLRDHUP,但是不触发EPOLLERR和EPOLLHUP。
关于这点,以前一直以为会触发EPOLLERR或者EPOLLHUP
再man epoll_ctl看下后两个事件的说明,这两个应该是本端(server端)出错才触发的。
5、对端异常断开连接(只测了拔网线),没触发任何事件。
附man:
EPOLLIN
The associated file is available for read(2) operations.
EPOLLOUT
The associated file is available for write(2) operations.
EPOLLRDHUP
Stream socket peer closed connection, or shut down writing half
of connection. (This flag is especially useful for writing sim-
ple code to detect peer shutdown when using Edge Triggered moni-
toring.)
EPOLLPRI
There is urgent data available for read(2) operations.
EPOLLERR
Error condition happened on the associated file descriptor.
epoll_wait(2) will always wait for this event; it is not neces-
sary to set it in events.
EPOLLHUP
Hang up happened on the associated file descriptor.
epoll_wait(2) will always wait for this event; it is not neces-
sary to set it in events.
EPOLLET
Sets the Edge Triggered behavior for the associated file
descriptor. The default behavior for epoll is Level Triggered.
See epoll(7) for more detailed information about Edge and Level
Triggered event distribution architectures.
EPOLLONESHOT (since Linux 2.6.2)
Sets the one-shot behavior for the associated file descriptor.
This means that after an event is pulled out with epoll_wait(2)
the associated file descriptor is internally disabled and no
other events will be reported by the epoll interface. The user
must call epoll_ctl() with EPOLL_CTL_MOD to re-enable the file
descriptor with a new event mask.
原文:http://www.cppblog.com/yangsf5/archive/2009/03/12/76353.html
继续深入学习:http://www.ccvita.com/515.html
以下内容均为转载(后面给出了原文的连接)
1、listen fd,有新连接请求,触发EPOLLIN。
2、对端发送普通数据,触发EPOLLIN。
3、带外数据,只触发EPOLLPRI。
4、对端正常关闭(程序里close(),shell下kill或ctr+c),触发EPOLLIN和EPOLLRDHUP,但是不触发EPOLLERR和EPOLLHUP。
关于这点,以前一直以为会触发EPOLLERR或者EPOLLHUP
再man epoll_ctl看下后两个事件的说明,这两个应该是本端(server端)出错才触发的。
5、对端异常断开连接(只测了拔网线),没触发任何事件。
附man:
EPOLLIN
The associated file is available for read(2) operations.
EPOLLOUT
The associated file is available for write(2) operations.
EPOLLRDHUP
Stream socket peer closed connection, or shut down writing half
of connection. (This flag is especially useful for writing sim-
ple code to detect peer shutdown when using Edge Triggered moni-
toring.)
EPOLLPRI
There is urgent data available for read(2) operations.
EPOLLERR
Error condition happened on the associated file descriptor.
epoll_wait(2) will always wait for this event; it is not neces-
sary to set it in events.
EPOLLHUP
Hang up happened on the associated file descriptor.
epoll_wait(2) will always wait for this event; it is not neces-
sary to set it in events.
EPOLLET
Sets the Edge Triggered behavior for the associated file
descriptor. The default behavior for epoll is Level Triggered.
See epoll(7) for more detailed information about Edge and Level
Triggered event distribution architectures.
EPOLLONESHOT (since Linux 2.6.2)
Sets the one-shot behavior for the associated file descriptor.
This means that after an event is pulled out with epoll_wait(2)
the associated file descriptor is internally disabled and no
other events will be reported by the epoll interface. The user
must call epoll_ctl() with EPOLL_CTL_MOD to re-enable the file
descriptor with a new event mask.
原文:http://www.cppblog.com/yangsf5/archive/2009/03/12/76353.html
继续深入学习:http://www.ccvita.com/515.html
相关文章推荐
- [转载] 理解 epoll 的事件触发机制
- DataGrid中DropDownList触发SelectedIndexChanged事件并修改DataGrid行值(转载)
- asp.net 页面回车触发button按钮事件-(转载)
- input输入框file类型选择同样输入框第二次不触发onchange事件的解决办法
- 【转载】Delphi7从子线程中发送消息到主线程触发事件执行
- C#代表元及事件触发 转载
- jquery 6 动态创建的元素的事件触发(转载)
- epoll的事件类型
- epoll的各个事件触发条件测试
- [置顶] js 触发事件种类类型有哪些?
- [转载] Winsock2中WSAAsynSelect()模型各种事件的触发条件
- [转载]Qt 软键盘[模拟]之键盘触发事件
- showModalDialog 访问父窗口,向父窗口返回值及undefined类型判断,js触发服务器控件事件
- [JQ权威指南]第十一天:使用trigger方法触发指定类型事件
- epoll 事件类型
- 我谈Silverlight架构和模式运用1-- ModelView模式最简单教程-讲解无代码触发事件,以及类型转换器的强大功能
- javascript判断触发事件event的元素类型
- 事件触发机制:Poll,Select和Epoll实现原理分析
- Linux网络编程--epoll模型ET触发模式之epolloneshot事件
- trigger() 方法触发被选元素的指定事件类型。