|
Boost Users : |
Subject: Re: [Boost-users] [asio] continuous reads into streambuf
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2018-05-24 23:53:52
Mere moments ago, quoth I:
> Instead of calling async_read with the total number of bytes you are
> expecting in the message body, first check how many bytes are already
> available in the streambuf (via size()), and only issue a read for the
> balance (and if the balance is 0 or negative, then obviously don't issue
> the read at all).
Also, don't forget to call consume on the streambuf once you have
finished using a chunk of data. (ie. after you have read the header
size, you need to consume all those bytes so that the remaining size()
no longer includes them, before you calculate the balance.)
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