![](/img/trans.png)
[英]C++: Boost::asio: Wait for asynchronous handler in the same function
[英]How can I get the amount of transferred bytes on asynchronous reading boost asio c++
正如我在Boost :: asio中看到的那样,异步读取函数不会返回传输的字节数,但普通读取函数会返回。 使用async_read_some时如何获取传输的字节数? (参数:缓冲区,处理程序)
所有形式的async_read
期望该形式的 “ ReadHandler
”回调
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.
);
回调的第二个参数是读取的字节数。
读取完成后,异步读取函数将调用“处理程序”函数(或函数对象)。 传输的字节数传递给该函数; 函数的签名必须是:
void handler(
const boost::system::error_code& error, // Result of operation.
std::size_t bytes_transferred // Number of bytes read.
);
读取处理程序的要求在此处记录
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.