Question

I've wrote an application that sends information through a socket using a TCP connection. For several reasons, I'm using blocking calls but I've noticed that boost::asio::write() method doesn't block when the other machine (the one receiving the data) disconnects. It doesn't raise an error either.

Is this the expected behavior?

Was it helpful?

Solution

Socket write will block when there is no room in the buffer, otherwise it will return as soon as data is in the buffer to send, not until data is delivered to the recipient. Also network stack may not detect that another side disconnected immediately, so you may or may not see error code on write. So yes, it is expected behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top