I am using boost::asio
to make server. But I want to know asio's mechanism. Let's start with some pseudo-code:
Pseudo Code (server)
async_read_some(MY::read1);
MY::read1() {
async_read_some(MY::read1);
async_write(someData); // someData : "ABCD"
}
Scenario
client:
send data to server.
send data to server.( not yet recv data ).
recv data from server.
Now I worry that received data is mixed from server.
expected : "ABCD" "ABCD"
wrong: "AABBCDCD"
Question
I know that async_write
function is guaranteed to be in order.
Thus, are the contents of the packets mixed?
Update:
Is this right?
async_read_some(MY::read1);
MY::read1() {
async_write(someData, MY::write1); // someData : "ABCD"
}
MY::write1() {
async_read_some(MY::read1);
}