Boost logo

Boost :

Subject: Re: [boost] Is the async_read more reliable than async_read_some?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-12-07 16:10:36


AMDG

On 12/07/2018 02:44 AM, hh h via Boost wrote:
> I have been using asio::async_read with protobuf for some time, it is
> relative easy to use protobuf function SerializeToOstream to attach a
> packet header and send the packet header along with to protobuf
> message, with fixed packet header size and message size in the header,
> I was able to use async_read.
>
> But I have to change to use msgpack which I could not find a way like
> protobuf to attach a packet header to msgpack message. The only way I
> could do is to use async_read_some, but I am very concerning the
> remark in the async_read_some document. Appreciate your comments.
>

How do you identify the end of the message?
Can you use one of the overloads of async_read
that takes a completion_condition?

> "The read operation may not read all of the requested number of bytes.
> Consider using the async_read function if you need to ensure that the
> requested amount of data is read before the asynchronous operation
> completes."
>

aynyc_read is essentially implemented by calling
async_read_some repeatedly, until it fills
the requested size.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk