disable the nagle algorithm to speed up write operations to the tcp connections (and dramatically improving write performance) fixes issue 50
This commit is contained in:
parent
93a0b60b6e
commit
e2ce7103aa
|
|
@ -25,6 +25,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <functional>
|
||||
|
||||
// forward declarations
|
||||
|
|
|
|||
|
|
@ -110,7 +110,17 @@ private:
|
|||
}
|
||||
|
||||
// connection succeeded, mark socket as non-blocking
|
||||
if (_socket >= 0) fcntl(_socket, F_SETFL, O_NONBLOCK);
|
||||
if (_socket >= 0)
|
||||
{
|
||||
// turn socket into a non-blocking socket
|
||||
fcntl(_socket, F_SETFL, O_NONBLOCK);
|
||||
|
||||
// we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w
|
||||
int optval = 1;
|
||||
|
||||
// set the option
|
||||
setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(int));
|
||||
}
|
||||
}
|
||||
catch (const std::runtime_error &error)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue