Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Asio -- combining sync read with async read
From: Igor R (boost.lists_at_[hidden])
Date: 2009-10-14 16:03:54


> If I have 2.5 lines in the buffer then the first two calls to getline will
give me the first two lines, but won't the third call to getline get me the
half line, and consume that half line from the streambuf? Do I need to
process the streambuf in a more manual fashion rather than calling getline
on the istream?

If this is the case in your application (i.e. the server might send few
lines in a bunch), then I think yes, you have to inspect the sterambuf
manually.
Actually, this is the reason I never used read_until - in most cases it
doesn't make your code simpler. The one case where it does is when your
protocol has a text header and a body (like in HTTP).

> if I was just processing one line in the async_handler, and the first time
the server sends me 3 lines, then the handler is called and will process the
first line sent. Then the server sends another 3 lines, the async handler is
called and the client will process the 2nd line that it received, not the
4th line, right?

Right, the data is added to the "get" area of the streambuf, you don't loose
anything. But if your server would not send anything more, there would not
be any trigger to continue processing the remained data.



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