简体   繁体   English

在没有物理连接的情况下进行boost异步tcp客户端不会返回错误

[英]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.

相关问题 当连接失败时,Boost ASIO ip tcp iostream expires_from_now不会导致错误 - Boost ASIO ip tcp iostream expires_from_now doesn't result in an error when connection fails 提升异步tcp客户端 - boost async tcp client async_connect不会在TCP客户端类中调用处理程序 - async_connect doesn't call handler in TCP client class Boost tcp_server async_write错误:访问冲突写入位置 - Boost tcp_server async_write error: access violation writing location boost::asio::ip::tcp::acceptor 在使用 async_accept 接收连接请求时终止应用程序 - boost::asio::ip::tcp::acceptor terminates application when receiving connection request using async_accept 当连接断开时,来自 boost::asio::async_write 的 WriteHandler 无法正常工作(防火墙/手动断开网络) - WriteHandler from boost::asio::async_write doesn't work properly when connection is dropped (firewall / manual disconecting the network) Boost TCP async_receive_some不会第二次读取 - Boost TCP async_receive_some doesn't read second time 在客户端终止连接过程后,c ++服务器无法关闭TCP套接字连接 - c++ server doesn't close TCP socket connection after the connection process is killed on client 异步套接字连接,服务器断开连接时,客户端GUI挂起TCP通信 - Async socket connection, Client GUI Hangs When Server is Disconnected TCP Communication boost ASIO async_read_until不能与ASIO ssl客户端示例一起编译 - boost ASIO async_read_until doesn't compile with ASIO ssl client example
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM