The prefix async
implies that the function runs asynchronously.
Simply call socket::receive
instead.
If you need to read a fixed number of bytes before the call returns, you'd better look at asio::read
, because the receive
operation may not receive all of the requested number of bytes.