remove TCP_NODELAY socket option, refactor when SO_LINGER is set on the socket options; correct some file formatting;

pull/33/head
Bryan Biedenkapp 3 years ago
parent 8c15cb5b50
commit ca7eb1a407

@ -83,6 +83,7 @@ namespace network
{
try
{
ensureNoLinger();
if (m_socket.is_open()) {
m_socket.close();
}
@ -90,6 +91,14 @@ namespace network
catch(const std::exception&) { /* ignore */ }
}
/// <summary>Helper to enable the SO_LINGER socket option during shutdown.</summary>
void ensureNoLinger()
{
// enable SO_LINGER timeout 0
asio::socket_base::linger linger(true, 0);
m_socket.set_option(linger);
}
/// <summary>Perform an synchronous write operation.</summary>
void send(HTTPPayload request)
{
@ -126,9 +135,7 @@ namespace network
}
}
else if (ec != asio::error::operation_aborted) {
if (m_socket.is_open()) {
m_socket.close();
}
stop();
}
});
}

@ -164,14 +164,6 @@ namespace network
{
asio::connect(m_socket, endpoints);
// enable SO_LINGER timeout 0
asio::socket_base::linger linger(true, 0);
m_socket.set_option(linger);
// enable TCP_NODELAY
asio::ip::tcp::no_delay noDelay(true);
m_socket.set_option(noDelay);
m_connection = new_unique(ConnectionType, std::move(m_socket), m_requestHandler);
m_connection->start();
}

Loading…
Cancel
Save

Powered by TurnKey Linux.