
26 Mar
2009
26 Mar
'09
2:53 p.m.
Igor R wrote:
How could i make it so i can set the buffer to use at the exact moment in which data for a new request in an already open connection begins to arrive?
You can make initial calls to async_read (or whatever read function you use) with buffer of 1 byte. When the handler is called, i.e. some data is available, you can perform "speculative" read (even synchronous) of all the data available - into any buffer you wish.
There is no need for a 1 byte buffer - ASIO provides null_buffers() for this purpose. See e.g. http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/overview/core/react... HTH, Juraj