问题描述
- 处理EPOLLIN事件 recv MSG_PEEK 返回 EAGAIN
-
处理EPOLLIN事件
n = recv(fd, buf, 1, MSG _ PEEK);
返回-1, errno是EAGAIN, 请问是怎么回事。
通过tcpdump看到的确是有数据来了
解决方案
参考:http://bbs.chinaunix.net/thread-1850751-1-1.html
http://bbs.csdn.net/topics/390335223
解决方案二:
http://stackoverflow.com/questions/3664537/nonblocking-socket-recv-problem-while-using-it-with-epoll上说epoll_wait() only told you that there was a new socket to accept() - it did not tell you that there was data to read from the new socket.
真的是这样的吗?
为啥有数据epoll告诉有数据,(这里已排除对端close的情况,),调recv却还是EAGAIN. 这种情况在大量请求时仅出现过很少次。
解决方案三:
http://stackoverflow.com/questions/3664537/nonblocking-socket-recv-problem-while-using-it-with-epoll
时间: 2024-09-20 17:11:35