Boost logo

Boost Users :

Subject: Re: [Boost-users] asio::ip::tcp iostream wrong byte count read for last packet
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-08-10 18:50:55

On 9/08/2014 04:58, Steve Coleman wrote:
> My problem is in getting the correct byte count read in the final packet
> received. My last frame always returns the size of the buffer, not the
> number of bytes read into the buffer. Isn't iostream::gcount(() meant
> for this? If not, what is the correct 'Boost' way of doing this?

"read" returns the number of bytes actually read. Use that.

(If you later switch to doing an async read, then it is one of the
parameters that can be passed to the callback function.)

Depending on what you're reading, you may also want to use one of the
read* free functions to guarantee reading exactly or at least a
specified number of bytes, or up to a specified delimiter.

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