Several buffers are combined in ConstBufferSequence :
std::array<char, 128> b0 = {0}; std::array<char, 128> b1 = {0}; std::vector<boost::asio::const_buffer> bufs; bufs.push_back(boost::asio::buffer(b0)); bufs.push_back(boost::asio::buffer(b1));
It is necessary to get a stream reading of all buffers, as if it were one continuous buffer (at least you need the function of reading a portion of a given size with the return of the actual number of bytes read).
So far this is done trivially - by traversing all buffers and copying the contents into a separate buffer with which further work is going on (unnecessary copy is obtained).
The boost::asio::detail::consuming_buffers
source has boost::asio::detail::consuming_buffers
, which is used, for example, in boost::asio::write
to bypass all buffers. Those. The input boost::asio::write
can be used to send ConstBufferSequence from several buffers that will be used sequentially.
I have not yet found the official way to use ConstBufferSequence for reading. Is it worth cycling the code for this, or is there still a trueway?
consume()
, etc. - strangeqargo