我在网上读了文件abount edge触发的epoll函数,如下所示:
1. The file descriptor that represents the read side of a pipe (rfd) is registered on the epoll instance.
2. A pipe writer writes 2 kB of data on the write side of the pipe.
3. A call to epoll_wait(2) is done that will return rfd as a ready file descriptor.
4. The pipe reader reads 1 kB of data from rfd.
5. A call to epoll_wait(2) is done.
.......
.......
Run Code Online (Sandbox Code Playgroud)
使用epoll作为边缘触发(EPOLLET)接口的建议方法如下:i)使用非阻塞文件描述符ii)仅在read(2)或write(2)返回EAGAIN之后为事件调用epoll_wait.
我理解2,但我不知道为什么使用非阻塞文件描述符.
谁能解释为什么使用非阻塞文件描述符的原因?为什么在级别触发的epoll函数中使用阻塞文件描述符是可以的?