clinuxsocketsepollberkeley-sockets

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


I have a fd:

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

And I have a epoll instance. I need to know, what events should I subscribe to via epoll_ctl? I need Edge Triggered mode.

I have those flags atm: EPOLLET | EPOLLIN

Should I subscribe to EPOLLRDHUP, EPOLLOUT, EPOLLPRI ?

Should I handle EPOLLHUP, EPOLLERR ? Why they can occur?


Solution

  • 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:

    Also the example doesn't handle EPOLLHUP, EPOLLERR for the listening socket. That's at least understandable for EPOLLHUP, since that applies to output only. I know of no case where EPOLLERR would be returned for the passive socket.