简体   繁体   English

epoll ET,我应该在监听套接字上订阅哪些事件?

[英]epoll ET, what events should I subscribe to on listening socket?

I have a fd: 我有一个FD:

socket(AF_INET6, SOCK_STREAM, ...)
bind(fd, ...)
listen(fd, ...)

And I have a epoll instance. 我有一个epoll实例。 I need to know, what events should I subscribe to via epoll_ctl ? 我需要知道,我应该通过epoll_ctl订阅哪些事件? I need Edge Triggered mode. 我需要边缘触发模式。

I have those flags atm: EPOLLET | EPOLLIN 我有那些标志atm: EPOLLET | EPOLLIN EPOLLET | EPOLLIN

Should I subscribe to EPOLLRDHUP , EPOLLOUT , EPOLLPRI ? 我应该订阅EPOLLRDHUPEPOLLOUTEPOLLPRI吗?

Should I handle EPOLLHUP , EPOLLERR ? 我应该处理EPOLLHUPEPOLLERR吗? Why they can occur? 为什么会发生?

You ask specifically about the passive socket used to accept incoming connection requests. 您专门询问用于接受传入连接请求的被动套接字。 The example in man epoll doesn't subscribe to EPOLLRDHUP , EPOLLOUT , EPOLLPRI for the listening socket, and understandably so: man epoll中的示例未为侦听套接字订阅EPOLLRDHUPEPOLLOUTEPOLLPRI ,因此可以理解:

  • EPOLLOUT means: Writing now will not block. EPOLLOUT意思是: 现在写入将不会阻塞。 - There is no writing on the passive socket. -无源插座上没有任何文字。
  • EPOLLRDHUP applies to connections. EPOLLRDHUP适用于连接。 There isn't a connection on the passive socket. 无源套接字上没有连接。
  • EPOLLPRI means: There is urgent data to read . EPOLLPRI意思是: 有紧急数据要读取 There's no urgent data on a passive socket. 无源套接字上没有紧急数据。

Also the example doesn't handle EPOLLHUP , EPOLLERR for the listening socket. 同样,该示例不为侦听套接字处理EPOLLHUPEPOLLERR That's at least understandable for EPOLLHUP , since that applies to output only . 这对于EPOLLHUP至少是可以理解的,因为这仅适用于输出 I know of no case where EPOLLERR would be returned for the passive socket. 我不知道在任何情况下EPOLLERR将为被动套接字返回EPOLLERR

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM