[英]boost async tcp client doesn't return error when writing without physical connection
I'm trying to use this example of blocking socket : http://www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_tcp_client.cpp 我正在尝试使用此示例阻止套接字: http : //www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/example/timeouts/blocking_tcp_client.cpp
TEST 测试
I wanted to test its behavior so I tried to unplug my ethernet cable and keep writing every seconds. 我想测试其行为,因此尝试拔出以太网电缆并保持每秒写入一次。
BEHAVIOR 行为
The write function continues to send messages without catching any error for about 20s and then finally catch an error (on tcp timeout ?). 写入功能继续发送消息约20秒,而没有捕获任何错误,然后最终捕获了一个错误(tcp超时吗?)。 I defined my own deadline as 1s.
我将自己的截止日期定义为1s。
PROBLEM 问题
It was expecting that i'd get an error at the first call of write function, after about 1s. 预计大约1秒后,我将在第一次调用write函数时收到错误消息。 Why don't I catch an error at this first call, instead of 20s later ?
为什么在第一次通话时而不是20秒后才出现错误? And is there a way to do it ?
有办法吗?
This is expected from TCP, and there is nothing you can do about it. 这是TCP所期望的,您对此无能为力。 TCP does not guarantee delivery, it makes a best effort attempt to ensure one.
TCP不保证交付,它尽最大努力确保保证交付。
If you want trully guaranteed delivery, you have to ACK your submission in the application code. 如果您希望得到完全保证的交付,则必须在应用程序代码中确认提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.