关于 c:在 select() 调用的上下文中,连接超时意味着什么 | 珊瑚贝

What does a Connection Timeout mean in the context of a select() call


我注意到有时选择返回连接超时设置为 errno,但我不知道它为什么会这样做,它怎么知道?你打算如何处理这个问题? (我猜这意味着其中一个连接超时,也许在适当的时间没有收到 ACK)。我想唯一合法的情况是如果服务器套接字在那里并且您之前运行了非阻塞连接?在这种情况下,再次在此套接字上运行连接将返回给您,无论它是否已连接,这将是处理该问题的方法….但是有更好的方法吗?

提前致谢。

  • 是的,这应该只发生在非阻塞 connect 中,但我忘记了将非阻塞 connect 与 select 一起使用的正确方法,所以我将其写为评论而不是答案。


正如上面的评论者所说,这可能是非阻塞 connect() 上的 select() 的结果。除非这通常是超时,在这种情况下,有时也会发生传入接受的 TCP 套接字。无论哪种方式,以下是两个非常有用的指南,可帮助您刷新对 select() 的使用的记忆:

http://www.lowtek.com/sockets/select.html

http://beej.us/guide/bgnet/output/html/multipage/advanced.html#select

http://beej.us/guide/bgnet/output/html/multipage/advanced.html#blocking

另请参阅此问题以获取 Python 示例:

如何获得非阻塞套接字 connect()?

干杯。


来源:https://www.codenong.com/4356996/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9344.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?