epoll 事件 epollin 发生,第一次recv 是EAGAIN?
关注者
5被浏览
3,598登录后你可以
不限量看优质回答私信答主深度交流精彩内容一键收藏
非阻塞socket的方式下,EPOLLIN事件并不一定表示有数据,recv的man手册上提到:If no messages are available at the socket, the receive calls wait for a message to arrive, unless the socket is nonblocking (see fcntl(2)), in which case the value -1 is returned and the external variable errno is set to EAGAIN or EWOULDBLOCK.
errno为EAGAIN继续等下一个事件处理即可,具体可看这里: