Boost logo

Boost Users :

Subject: Re: [Boost-users] What is the way to access the data contained in a stream buffer?
From: Igor R (boost.lists_at_[hidden])
Date: 2009-09-13 05:32:53


> We can see in these 2 lines of code that we are mixing STL with Boost:
>
>  boost::asio::streambuf request;
>  std::ostream request_stream(&request);
>
> Is there any STL class that can be used above, instead of
> boost::asio::streambuf?
>
> I am trying to have a better feeling for the different implementations and
> choices among streams and buffers.

asio socket's member functions that write data to the socket, like
async_write_some() or async_send(), get a
ConstBufferSequence-complient buffer as a parameter:
http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/reference/basic_stream_socket/async_write_some.html
http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/reference/ConstBufferSequence.html

There's a "buffer" class that can adapt virtually any physical buffer
type to comply with ConstBufferSequence:
http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/reference/buffer.html

The free function boost::asio::write() is just a convenience function
that one of its overloads take an asio::streambuf:
http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/reference/write.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net