
On Mon, Jul 21, 2025 at 1:55 PM Dennis Luehring via Boost <boost@lists.boost.org> wrote:
is it possible that the async_write handler comes after the async_read handler?
Asio does not provide any guarantees in this regard. The behavior depends entirely on the implementation of the network stack and the event notification mechanism used by the operating system. For example, on Linux with the epoll API:
If more than maxevents file descriptors are ready when epoll_wait() is called, then successive epoll_wait() calls will round robin through the set of ready file descriptors. This behavior helps avoid starvation scenarios, where a process fails to notice that additional file descriptors are ready because it focuses on a set of file descriptors that are already known to be ready.
This clearly violates your requirements. Even if we assume no reordering occurs in the network stack.