简体   繁体   English

带有errno = 107的recv():(连接传输端点)

[英]recv() with errno=107:(transport endpoint connected)

well..I use a typical model of epoll+multithread to handle massive sockets, that is, I have a thread called epollWorkThread that use epoll_wait to handle i/o sockets. 好吧。我使用典型的epoll +多线程模型来处理大量套接字,也就是说,我有一个名为epollWorkThread的线程,它使用epoll_wait来处理i / o套接字。 While there's an event of EPOLLIN, recv() will do the work and I do use the noblocking mode to allow immediate return. 虽然有一个EPOLLIN事件,但recv()将完成工作,我确实使用noblocking模式允许立即返回。 And recv() is indeed in a while(true) loop. 并且recv()确实处于while(true)循环中。 Everything is fine in the intial time(maybe a couple of hours or maybe minutes or if I'm lucky days), I can receive the information. 在最初的时间(可能是几个小时或者几分钟,或者如果我是幸运的日子),一切都很好,我可以收到信息。 But some time later, recv() insists to return -1 with the errno = 107(ENOTCONN). 但是一段时间后,recv()坚持用errno = 107(ENOTCONN)返回-1。 The other peer of the transport is written in AS3 which makes sure that the socket is connected. 传输的另一个对等体是用AS3编写的,它确保套接字已连接。 So I'm confused by the recv() behaviour. 所以我对recv()行为感到困惑。 Thank you in advance and any comment is appreciated! 提前谢谢,任何评论表示赞赏!

Errno 107 means that the socket is NOT connected (any more). 错误号107指套接字连接(任何更多)。 There are several reasons why this could happen. 有几个原因导致这种情况发生。 Assuming you're right and both sides of the connection claim that the socket is still open, an intermediate router/switch may have dropped the connection due to a timeout. 假设您是正确的并且连接的两端都声称套接字仍处于打开状态,则中间路由器/交换机可能由于超时而丢弃了连接。 The safest way to avoid such things from happen is to periodically send a 'health' or 'keep-alive' message. 避免此类事件发生的最安全方法是定期发送“健康”或“保持活跃”的消息。 (Thus the intermediate router/switch accepts the connection as living...)= (因此中间路由器/交换机接受连接为生活...)=

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM