Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Asio -- combining sync read with async read
From: Sameer Parekh (sameer_at_[hidden])
Date: 2009-10-15 11:47:46


Igor--
   So I'm not sure what you mean exactly by "the server might send a
few lines in a bunch." The server will only send one line at a time,
in that it will call write_async for every line that it sends-- it
will never call write_async on more than one line. However, the client
might be doing some processing so the server might send a few lines
before the client "comes up for air" next. If that's the case then all
three lines will end up in the same buffer when the read_async handler
is called? I would imagine so but it would be nice if I could not
worry about this, so I am looking for any excuse. =)

   I also realized upon looking at the chat example in more detail
that I missed the whole queue thing that it does. I will aim to
replicate that in my app now. In reading through, it occurs to me that
I might be making the same mistake with write_async -- i.e. if I call
write_async twice in quick succession, that could cause a problem
unless I wait for the first write_async to complete before I call
write_async a second time?

Best,
-Sameer

On Oct 14, 2009, at 6:21 PM, boost-users-request_at_[hidden] wrote:

> 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).


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