Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
Improve TCP/IP responsiveness.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikogenvik committed Apr 10, 2014
1 parent dd816e4 commit d25bebd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Eris/BaseConnection.cpp
Expand Up @@ -76,7 +76,12 @@ int BaseConnection::connect(const std::string & host, short port)
StreamSocket::Callbacks callbacks;
callbacks.dispatch = [&] {this->dispatch();};
callbacks.stateChanged =
[&](StreamSocket::Status state) {this->stateChanged(state);};
[&](StreamSocket::Status state) {
if (state == StreamSocket::NEGOTIATE) {
//Turn off Nagle's algorithm to increase responsiveness.
((ResolvableAsioStreamSocket<ip::tcp>*)_socket.get())->getAsioSocket().set_option(ip::tcp::no_delay(true));
}
this->stateChanged(state);};
auto socket = new ResolvableAsioStreamSocket<ip::tcp>(_io_service, _clientName,
_bridge, callbacks);
_socket.reset(socket);
Expand Down
1 change: 1 addition & 0 deletions Eris/StreamSocket.h
Expand Up @@ -159,6 +159,7 @@ class AsioStreamSocket: public StreamSocket
virtual ~AsioStreamSocket();
void connect(const typename ProtocolT::endpoint& endpoint);
virtual void write();
typename ProtocolT::socket& getAsioSocket();
protected:
typename ProtocolT::socket m_socket;
virtual void negotiate_read();
Expand Down
6 changes: 6 additions & 0 deletions Eris/StreamSocket_impl.h
Expand Up @@ -62,6 +62,12 @@ AsioStreamSocket<ProtocolT>::~AsioStreamSocket()
}
}

template<typename ProtocolT>
typename ProtocolT::socket& AsioStreamSocket<ProtocolT>::getAsioSocket()
{
return m_socket;
}

template<typename ProtocolT>
ResolvableAsioStreamSocket<ProtocolT>::ResolvableAsioStreamSocket(
boost::asio::io_service& io_service, const std::string& client_name,
Expand Down

0 comments on commit d25bebd

Please sign in to comment.