Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] multiple simultaneous async_read calls
From: Jason Roehm (jasonr_at_[hidden])
Date: 2014-08-07 22:17:17

On 08/07/2014 09:54 PM, bbxiong wrote:
> Hello, all,
> If i write some code like this:
> boost::asio::async_read(socket_, bosot::asio::buffer(,
> len1, handler1);
> boost::asio::async_read(socket_, boost::asio::buffer(,
> len2, handler2);
> Will asio guarantee len1 bytes received by the first async_read, then
> schedule async_read2?
> or the result is undefined(like several bytes filled into buffer1,
> then next several bytes into buffer, then next several bytes into
> buffer1)?

I don't believe you're guaranteed that you will get `len1` bytes from
the first read; it could be shorter. If you want to ensure that you get
exactly that size in the first read, you should use the
`transfer_exactly` completion condition:


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at