Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost::Asio read_until and streambuf usage
From: Igor R (boost.lists_at_[hidden])
Date: 2012-11-22 14:06:26


>> Do you expect std::getline to give you more than 1 line?
>
> No, sorry I was not clear. I expect the streambuf or read_until to have
> some way of telling me there's more lines to read. With that piece of code,
> the streambuf swallows multiple lines, but getline only gets to the first
> line. Only when read_until is run again, the other lines appear. I need to
> poll? the socket for more data, but not sure how that is done in asio.

The point is that read_until() may read *more* data than you asked,
but std::getline() always extracts chars until it encounters eol or
until error occurs. So you can iterate over getline() until error in
the istream state -- the last extracted string would be incomplete, so
it should be appended by the next result of read_until.
Alternatively, you can scan the streambuf contents manually, find
eol's and split the whole input as you wish.


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