It seems like boost 1.40.0 has changed the way it works async_read_some().
Previously, you could pass null_buffer, and you will receive a callback when there is data to read, but without reading frames into any buffer (because there were none!). This basically allowed you to write code that acted like a call select(), where you would be told when your socket has some data.
In the new code, the behavior has been changed to work as follows:
If the total size of all the buffers in the mb sequence is 0, the asynchronous read operation should immediately end and pass 0 as an argument to the handler, which determines the number of bytes read.
This means that my old (and by the way the method shown in this official example ) method of detecting data in a socket no longer works. The problem for me is that I need a way to detect this, because I imposed my own stream classes on top asio socket streams and as such, I can't just read the socket data that my streams will expect from them. The only workaround I can come up with right now is to read one byte, save it, and when my stream classes request a few bytes, return that byte if it is set: not really.
Does anyone know how best to implement this type of behavior in the latest updated boost.asio code?
source
share