boost::asio async_read guarantee all bytes are read

前端 未结 3 1837
悲&欢浪女
悲&欢浪女 2020-12-06 12:59

I have a server that receives a compressed string (compressed with zlib) from a client, and I was using async_receive from the boost::asio library

3条回答
  •  离开以前
    2020-12-06 13:45

    How were you expecting to do this using any other method?

    There are a few general methods to sending data of variable sizes in an async manor:

    1. By message - meaning that you have a header that defines the length of the expected message followed by a body which contains data of the specified length.
    2. By stream - meaning that you have some marker (and this is very broad) method of knowing when you've gotten a complete packet.
    3. By connection - each complete packet of data is sent in a single connection which is closed once the data is complete.

    So can your data be parsed, or a length sent etc...

提交回复
热议问题