0

I have an issue with boost::async_read().
Online, I found that there is a function read_at_least(n). But I'm looking for a function like read_max() which would read a maximum amount of bytes.

The thing is that I have different structures to read, each of them beginning by the size of the structure itself. I would like to be able to do things like :

int s = async_read([...], read_at_least(4), read_max(4));
async_read([...], read_at_least(s), read_max(s));

The problem of not doing this is that I have to store the rest of the read operation in cases it reads for more than I wanted.

Thank you in advance, Florian

DKF
  • 407
  • 3
  • 5
  • 10

1 Answers1

2

Have you seen the documentation, basically, provide a completion condition to the read operation where you specify exactly the number of bytes you want to read.

Nim
  • 33,299
  • 2
  • 62
  • 101