很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

Epoll触发事件的类型(转载)相关推荐

  1. epoll触发事件的分析

    我们知道,可以将套接字放入到epoll中监听,当套接字上有事件发生时,epoll就会通知我们.epoll机制可以监听套接字上的以下6种事件: EPOLLIN:套接字可读 EPOLLOUT:套接字可写 ...

  2. layui使用tips_使用layer.tips实现鼠标悬浮时触发事件提示消息实现

    代码: 你瞅啥!?过来试试! 方法一: function show(id) { layer.tips("左边么么哒", "#"+id+"", ...

  3. JQuery 自己主动触发事件

    经常使用模拟 有时候,须要通过模拟用户操作,来达到单击的效果.比如在用户进入页面后,就触发click事件,而不须要用户去主动单击. 在JQuery中.能够使用trigger()方法完毕模拟操作.比如能 ...

  4. 在C#中使用代理的方式触发事件 (委托和事件 ) (转)

    From:  http://www.cnblogs.com/gzhnan/articles/1859477.html 在C#中使用代理的方式触发事件 (委托和事件 ) 事件(event)是一个非常重要 ...

  5. 在C#中使用代理的方式触发事件

    事件(event)是一个非常重要的概念,我们的程序时刻都在触发和接收着各种事件:鼠标点击事件,键盘事件,以及处理操作系统的各种事件.所谓事件就是由某个对象发出的消息.比如用户按下了某个按钮,某个文件发 ...

  6. 关于Input内容改变的触发事件

    1.onchange onchange 事件会在域的内容改变时触发.支持的标签<input type="text">, <textarea>, <se ...

  7. 使用jQuery中trigger()方法自动触发事件

    一.常用事件 在页面加载完成时  自动触发input的点击事件,在移动端可以实现自动弹出输入法,获得焦点 $("input").trigger("click") ...

  8. wpf checkbox选中触发事件_Cypress 可操作事件

    click() 单击DOM元素语法如下: cy.get('.action-btn').click() // clicking in the center of the element is the d ...

  9. [unreal4入门系列之十四] 在UE4中添加碰撞触发事件

    一.在HUD中显示消息 1) 在MyHUD.h中定义一个结构来表示我们的消息: #pragma once #include "GameFramework/HUD.h" #inclu ...

最新文章

  1. 阿里AI大牛聂再清重返清华,加入张亚勤AIR战队
  2. 一文让你秒懂AQS,附带源码剖析!
  3. ASP.NET Core结合Nacos来完成配置管理和服务发现
  4. JavaScript学习总结(二)——逻辑Not运算符详解
  5. hdu3966 树链剖分点权模板+线段树区间更新/树状数组区间更新单点查询
  6. 25个优秀的jQuery滑块教程和插件
  7. cathome 猫家 开发日记-底部导航
  8. cout不明确什么意思_年轻人不讲武德是什么梗和意思 年轻人不讲武德梗出处
  9. 汇编 align_从零开始自制操作系统(5):实模式汇编(二)
  10. keepalive+lvs负载均衡及高可用总结
  11. 【Android】PA4D_CH6 使用Internat资源
  12. 基于R语言的地理探测器实现与问题研究
  13. 一线互联网公司的前端开发流程
  14. 企业计算机网络安全威胁及措施
  15. 利用IPv6看清晰流畅的网络电视
  16. 个人数字证书免费申请
  17. 百度语音识别开放平台SDK使用方法
  18. C语言提高代码效率的几种方法,7个提升嵌入式C代码效率的方法-嵌入式系统-与非网...
  19. LP wizard无法生成PCB封装
  20. C#:Krypton控件使用方法详解(第十六讲) ——kryptonCheckedListBox

热门文章

  1. 子网掩码和prefixlength
  2. 开源博客项目eblog完整搭建教程!
  3. 基于java的家庭理财系统
  4. 道阻且长 莫失本心(我的OI之旅
  5. java题算工资_Java模版方法的小练习——工资系统
  6. 鱼的记忆[较为重要的知识点/技巧]
  7. Apache http Server与Tomcat整合 2
  8. JS如何区分微信浏览器、QQ浏览器和QQ内置浏览器,解决 ios 无法判断是否为qq浏览器环境的问题。
  9. 【香蕉oi】Tree(欧拉序、线段树)
  10. 移动4G网络App页面加载时间过长