我的代码使用 epoll 进行多路复用。遇到 EPOLLIN 后,它从就绪套接字中读取一个字节。
read(fd, &onebyte, 1);
上面的行能返回EWOULDBLOCK吗?
最佳答案
是的,
Errors:
...
EAGAIN or EWOULDBLOCK
The file descriptor fd refers to a socket and has been marked nonblocking (O_NONBLOCK), and the read would block. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities
关于套接字中的 read() 可以返回 EWOULDBLOCK 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50784220/