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-21 12:56:20


> I have a server that sends three lines, each of which have to be parsed
> independently.
> I am using read_until but have a problem with its usage. When read_until
> reads once, the streambuf seems to contain the three lines but not in the
> istream and only when I call read_until several times, I get the lines.
> I am wondering how can I safely read_until the buffer is empty (the 3 or
> more lines are read) and then exit the loop.
>
> boost::asio::streambuf buf;
>
> while( 1 )
>
> {
> size_t reply_length = boost::asio::read_until( socket_,
> buf, '\n' );
>
> std::istream is(&buf);
> std::string reply;
> std::getline(is, reply); // only 1 line obtained
>
> }

Do you expect std::getline to give you more than 1 line?


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