EPOLLIN
The associated file is available for read(2) operations.
关联文件描述符的有效读操作
EPOLLOUT
The associated file is available for write(2) operations.
关联文件描述符的有效写操作
EPOLLRDHUP (since Linux 2.6.17)
Stream socket peer closed connection, or shut down writing
half of connection. (This flag is especially useful for
writing simple code to detect peer shutdown when using
edge-triggered monitoring.)
提供给底层系统检测网络的半关闭状态,不用把结果使用EPOLLOUT提供给上层逻辑处理
EPOLLPRI
There is an exceptional condition on the file descriptor.
See the discussion of POLLPRI in poll(2).
• There is out-of-band data on a TCP socket (see tcp(7)). • A pseudoterminal master in packet mode has seen a state change on the slave (see ioctl_tty(2)). • A cgroup.events file has been modified (see cgroups(7)).
三种exceptional condition,第一个是TCPsocket 有外带数据
EPOLLERR
Error condition happened on the associated file
descriptor. This event is also reported for the write end
of a pipe when the read end has been closed.
epoll_wait(2) will always report for this event; it is not
necessary to set it in events when calling epoll_ctl().
可以理解为对关联文件描述符的操作出错时的事件,可以不用主动设置
EPOLLHUP
Hang up happened on the associated file descriptor.
epoll_wait(2) will always wait for this event; it is not
necessary to set it in events when calling epoll_ctl().
Note that when reading from a channel such as a pipe or a
stream socket, this event merely indicates that the peer
closed its end of the channel. Subsequent reads from the
channel will return 0 (end of file) only after all
outstanding data in the channel has been consumed.
事件不用主动设置;当读取一个类似pipe这样的通道时,事件仅显示对方关闭通道。
EPOLLET
Requests edge-triggered notification for the associated
file descriptor. The default behavior for epoll is level-
triggered. See epoll(7) for more detailed information
about edge-triggered and level-triggered notification.
This flag is an input flag for the event.events field when
calling epoll_ctl(); it is never returned by
epoll_wait(2).
请求文件描述符的边界触发通知,EPOLLET应该设置为非阻塞模式的请求,避免出现永久阻塞的情况。
The suggested way to use epoll as an edge-triggered (EPOLLET) interface is as follows: a) with nonblocking file descriptors; and b) by waiting for an event only after read(2) or write(2) return EAGAIN.
参考:
https://man7.org/linux/man-pages/man2/epoll_ctl.2.html
https://www.cnblogs.com/lexus/archive/2013/03/29/2988825.html
https://lkml.org/lkml/2003/7/12/116
https://man7.org/linux/man-pages/man7/epoll.7.html