Boost::Asio : Problem with async_read?

I suspect what is happening is that one of your async_read_some calls is returning "some" data, but not enough for the SQL server to be satisfied that it has received a complete request. You code always follows the path of read_from_client -> send_to_server -> read_from_server -> send_to_client. It does not handle the case where you need read_from_client -> send_to_server - >read_from_client -> send_to_server -> read_from_server -> send_to_client.

I suspect what is happening is that one of your async_read_some calls is returning "some" data, but not enough for the SQL server to be satisfied that it has received a complete request. You code always follows the path of read_from_client -> send_to_server -> read_from_server -> send_to_client. It does not handle the case where you need read_from_client -> send_to_server - >read_from_client -> send_to_server -> read_from_server -> send_to_client.

The code you have written so far does not perform the same operations as the original. Specifically, the old code was simultaneously listening for reads on both sockets. Fortunately, since you're using ASIO, you don't need to mess with threads.

Just issue issue simultaneous async_read_some requests on both sockets and deal with them asynchronously.

1 I just had to do the same sort of thing with async_read_some(). When implementing some sort of request processor, you must provide some processing in the handle_read() to put together one or more reads into complete requests. – Lou Jun 4 at 4:03 +1 nice analysis, I suspect this is the problem.

– Sam Miller Jun 4 at 14:47 Thanks for the answer, I will try to check if there is more data to be read from the socket and, if so, handle it in my read callback methods. – user782457 Jun 13 at 7:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions