I'm having trouble implmenting the 3rd parameter in the function documented here: http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/reference/async_read_until/overload4.html What I'd like to be able to do is use the callback on the 3rd parameter of async_read_until to detect when a complete chunk has arrived. My packets have the following format.
- 1 byte id (semantic meaning of the data)
- unsigned int (the number of bytes in the data, since some data chunks can change size)
- payload
Looking at the example code in the documentation, I'm a little confused about how I'm supposed to be able to extract a byte, let alone an unsigned int from the begin and end iterators.
I've instantiated my iterators as
typedef boost::asio::buffers_iterator<
boost::asio::streambuf::const_buffers_type> iterator;
but even then I'm not sure what type that is, since I don't know what const_buffers_type is. I followed some links in the documentation and found out it was "implementation defined", but I guess I could be wrong. So my two concrete questions are:
- how can I use those two iterators to read an unsigned int?
- what type are those iterators pointing to?
Thanks!