Boost :: asio how to read full buffer correctly?

I am learning boost :: asio and now am messing up the correct path to read the full buffer. For example, when the connection is established, I want to read int32 as follows:

std::uint32_t size;
size_t len = m_socket.read_some(buffer(&size, sizeof(std::uint32_t)));

As you can see, I am adjusting the size of the buffer. In another case, I got "len" with read_some data duration.

So, the main question: is boost :: asio guaranteed that all 4 uint32_t bytes will be read if I configure the required buffer length when calling 'buffer'?

Or, if it is not insured - how can I read the full buffer? (all 4 bytes)

+4
source share
1 answer

In the read_somelink:

. , , .

:

read_some . read, , .

, read_some , read, :

:

  • . , .
  • .

read_some.

read :

std::uint32_t size;
size_t len = read(m_socket, buffer(&size, sizeof(std::uint32_t)));
+6

All Articles