There are several things about boost.asio compound operations that are not clear from the official documentation and various threads that I have read on the topic.
The Scenario
Two boost::asio::async_write
requests A and B are scheduled on a single TCP socket.
Questions
- In a single-threaded process, can it happen that A is executed concurrently with B? Namely, intermediate calls to
async_write_some
of A are mixed with those of B (which essentially renders a corrupted stream)? - If the answer to (1) is Yes, does
io_service::strand
solve the issue in single-threaded process? Does it assure that all intermediate calls of A complete before B is started? - Does
io_service.strand
solve the issue of (1) in a multi-threaded process, when more than one thread executeio_service::run()
? Does it assure that all intermediate calls of A complete before B is started?