boost::asio::async_write() 与 boost::asio::write()
将数据缓冲区传输到网络上所需的时间是否有任何优势 如果你使用
boost::asio::write(m_socket, asio::buffer(dataOut_, len), asio::transfer_all());
而不是
boost::asio::async_write(m_socket, boost::asio::buffer(hbs, sizeof(hbs)),
boost::bind(&Client::handle_pulse, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
Is there any advantage in terms of the time it takes to get the data buffer out onto the wire
if you use
boost::asio::write(m_socket, asio::buffer(dataOut_, len), asio::transfer_all());
instead of
boost::asio::async_write(m_socket, boost::asio::buffer(hbs, sizeof(hbs)),
boost::bind(&Client::handle_pulse, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最大的区别是,普通的 write 会阻塞,直到全部写入,而 async_write 会在所有数据写入或发生错误时立即返回并调用回调。
我怀疑从调用到实际通过线路发送数据的时间有任何明显的差异。
The big difference is that the normal
write
can block until all is written, whileasync_write
returns immediately and calls a callback when either all data is written or an error occurs.I doubt there is any noticeable difference in time from call to the data actually being sent over the wire.