Boost logo

Boost Users :

Subject: Re: [Boost-users] [iostreams] Devices and WOULD_BLOCK
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-01-22 01:51:56


On 22/01/2015 18:40, David Hawkins wrote:
> Yep, I ran a few tests where I ensured that two complete messages
> were received into a boost::asio::streambuf and confirmed that
> read_until '[' returned the SOP first index, read_until ']' returned
> the first EOP index, I then consume()'d those characters and
> repeated the call to read_until and confirmed it returned immediately
> based on the streambuf contents. So this all works as described by
> the documentation.

Yep. Just be careful if you're mixing calls to read_until with calls to
read -- read_until may fetch a larger amount of data into the streambuf
(beyond the delimiter), while read will always wait for new data, even
if the streambuf isn't empty. So you need to explicitly check the
streambuf before calling read().

Of course if you're only dealing with purely delimited data then this
shouldn't be an issue, as you'll only be using [async_]read_until.

> Once I finish my variation on the chat client/server, I'd be happy
> to post the code. At a minimum it would provide code for people on
> the list to review/comment on, and any final version of the code
> would benefit anyone interested in reading streams containing
> a different style of packet than that used in the boost example
> chat client/server.

Asio has a dedicated mailing list
(https://lists.sourceforge.net/lists/listinfo/asio-users), which I
believe the library maintainer pays closer attention to than this list;
it may be worthwhile asking there. Maybe you could even get it included
in the official docs. :)

(I have some working streambuf code but it's not really in
consumable-example form.)


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