c++: BOOST_ASIO Server reply isn’t as expected?
Your comment
I think
handle_read()
callshandle_write()
recursively?
is close but not quite correct as there is no recursion here. The documentation explains this nicely:
Regardless of whether the asynchronous operation completes immediately
or not, the handler will not be invoked from within this function.
Invocation of the handler will be performed in a manner equivalent to
usingboost::asio::io_service::post()
.
Added emphasis is mine. Instead of recursion, It is better to think of these concepts as chaining since one operation such as async_write()
is initiated in the handler of another, such as async_read()
. The exact specifics depend on the protocol in use.
If you want the server to send the string 0123456789 to the client, fill your buffer before invoking async_write()
.
Read more here: Source link