日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Epoll触发事件的类型(转载)

發布時間:2024/3/12 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Epoll触发事件的类型(转载) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


很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触发事件的类型(转载)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。