On Wed, Dec 9, 2009 at 1:18 PM, Igor R <boost.lists@gmail.com> wrote:
> I'd like to be able to skip the buffer and just read directly to the stream
> with an event to notify me of the arrival of data.

You can use asio::streambuf. It inherits std::streambuf, and you can
use it with istream and ostream, just as you do with standard
streambufs. But note that any buffer must outlive the async.operation.


I found an example (below) but it seems to be pretty much the same as my current code to write to a character array and copy the buffer into the stream. It also looks like it might choke if the read was larger than 512 bytes.  Thanks for the suggestion anyway though.

boost::asio::streambuf b;

// reserve 512 bytes in output sequence
boost::asio::streambuf::const_buffers_type bufs = b.prepare(512);

size_t n = sock.receive(bufs);

// received data is "committed" from output sequence to input sequence
b.commit(n);