diff --git a/node/node.cpp b/node/node.cpp index 735da981..0269b259 100644 --- a/node/node.cpp +++ b/node/node.cpp @@ -88,6 +88,14 @@ node::do_accept() auto ep = self->acceptor_socket->remote_endpoint(); auto key = self->key_from_ep(ep); + // set tcp_nodelay option... + boost::system::error_code option_ec; + self->acceptor_socket->get_tcp_socket().set_option(boost::asio::ip::tcp::no_delay(true), option_ec); + if (option_ec) + { + LOG(error) << "failed to set socket option: " << option_ec.message(); + } + std::shared_ptr ws = self->websocket->make_unique_websocket_stream( self->acceptor_socket->get_tcp_socket()); diff --git a/node/session.cpp b/node/session.cpp index df5f478c..7f49f7b6 100644 --- a/node/session.cpp +++ b/node/session.cpp @@ -84,6 +84,15 @@ session::open(std::shared_ptr ws_factory) // we've completed the handshake... std::lock_guard lock(self->socket_lock); + + // set tcp_nodelay option + boost::system::error_code option_ec; + socket->get_tcp_socket().set_option(boost::asio::ip::tcp::no_delay(true), option_ec); + if (option_ec) + { + LOG(error) << "failed to set socket option: " << option_ec.message(); + } + self->websocket = ws_factory->make_unique_websocket_stream(socket->get_tcp_socket()); self->websocket->async_handshake(self->ep.address().to_string(), "/", [self, ws_factory](const boost::system::error_code& ec)