猿问

请教下使用async_read_some如何实现分次读取数据?

比如说服务器向客户端一次发送5.5K的数据,那么客户端使用async_read_some异步读取数据,一次读取1K,分6次读完,如何实现?

慕标5832272
浏览 118回答 1
1回答

吃鸡游戏

回调函数的格式:void handler( const boost::system::error_code& error, // Result of operation.std::size_t bytes_transferred // Number of bytes copied into the// buffers. If an error occurred,// this will be the number of// bytes successfully transferred// prior to the error.);std::size_t bytes_transferred 就是接收数据的长度。
随时随地看视频慕课网APP
我要回答