gpt4 book ai didi

c++ - Boost.Asio : The difference between async_read and async_receive

转载 作者:IT老高 更新时间:2023-10-28 23:18:33 29 4
gpt4 key购买 nike

async_read 和有什么区别?和 async_receive ?

最佳答案

async_receive 是一个仅接收到缓冲区的函数,但可能无法接收您要求的数量。 (它会相等或更少,永远不会更多。)

但是,

async_read 将始终收到您要求的金额,如其所述:

This function is used to asynchronously read a certain number of bytes of data from a stream. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:

  • The supplied buffers are full. That is, the bytes transferred is equal to the sum of the buffer sizes.
  • An error occurred.

页面唯一有点模糊的是 async_read 如果它没有得到那么多字节,并且连接正常关闭。 (这算作“错误”吗?)这可以通过快速测试来确定。 (然而,async_receive 只会给你它所得到的。)

关于c++ - Boost.Asio : The difference between async_read and async_receive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2982514/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com