[英]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
? 我应该订阅EPOLLRDHUP
, EPOLLOUT
, EPOLLPRI
吗?
Should I handle EPOLLHUP
, EPOLLERR
? 我应该处理EPOLLHUP
和EPOLLERR
吗? 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中的示例未为侦听套接字订阅EPOLLRDHUP
, EPOLLOUT
和EPOLLPRI
,因此可以理解:
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. 同样,该示例不为侦听套接字处理EPOLLHUP
, EPOLLERR
。 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.