10 Aug
2014
10 Aug
'14
10:50 p.m.
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.