Boost logo

Boost Users :

Subject: Re: [Boost-users] async_read_some
From: Andrew Holden (aholden_at_[hidden])
Date: 2012-04-30 09:53:36


On Saturday, April 28, 2012 4:57 AM, Christer Borgqvist wrote:
> Im playing around with the /boost_asio/example/http/server3
> and using POST method.
> The bytes_transferred is 231, but thats only the header and
> ends with \r\n\r\n, need to read the rest.
> Sometimes i get bytes_transferred to 1032, the right amount
> of data, sometimes i get bytes_transferred = 231, but if i
> print the buffer_ i have all the 1032 bytes.
> Is it right that the bytes in the buffer_ and the
> bytes_transferred is not the same?
>
> appreciate any help.
> /christer

It is normal for async_read_some to read less than the size requested.
Think of it as a request to read whatever is available up to a maximum
size.

If you wish to read the whole buffer, then check out
::boost::asio::async_read at
http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/reference/async
_read.html

Depending on your needs, you might also use
::boost::asio::async_read_until
http://www.boost.org/doc/libs/1_49_0/doc/html/boost_asio/reference/async
_read_until.html


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