ASIO ip::tcp::iostream and TCP_NODELAY

烈酒焚心 提交于 2019-12-04 04:53:48

问题


How do i set TCP_NODELAY option if i use ip::tcp::iostream? I need a socket for this, but i can't find how to extract it from iostream.


回答1:


use iostream::rdbuf()

#include <boost/asio.hpp>

int
main()
{
    boost::asio::ip::tcp::iostream stream;
    const boost::asio::ip::tcp::no_delay option( true );
    stream.rdbuf()->set_option( option );
}


来源:https://stackoverflow.com/questions/5706641/asio-iptcpiostream-and-tcp-nodelay

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!