I have a questions concerning boost::asio::ip::tcp::socket and the associated write functions. From reading the Wikipedia article on the TCP, I understand, that TCP contains acknowledgement messages as well as checksums. Unfortunaly, I can’t find any information on this in the boost::asio reference. As far as I understand boost::asio uses the OS implementation of the TCP, which should contain both features.
My question is what do the functions boost::asio::write or boost::asio::async_write guarantee when called with an boost::asio::ip::tcp::socket. So what does it mean if the function returns/the callback function is called without error. I can imagine some possibilities:
- Basically nothing, It only means that the program told the OS to send the data, but nothing more.
- Data is underway, meaning that the OS acknowledged that it has send the data.
- Data has arrived, meaning that a acknowledgement message from the other side was received.
- Data has arrived and is not corrupted, same as 3. plus that the checksum adds up.
If it is not 4. is there a way to enforce this using boost::asio (I mean within boost::asio, not implementing it yourself)?
Locally detected errors will be reported. Connection error will also be reported.
If you are using TCP, tcp-ack failure will be reported, but maybe at a later read or write call (when the os is notified of the tcp-hack failure).
So you can’t be sure that when you issue a write that it is actually received. no write error means that the os knows currently no errors on the tcp connection you are using and that he buffered your data internally to transmit it to the tcp peer.