diff options
| author | Gregory Maxwell <[email protected]> | 2015-10-21 23:52:29 +0000 |
|---|---|---|
| committer | Gregory Maxwell <[email protected]> | 2015-10-22 17:57:48 +0000 |
| commit | a4e28b3d1e5c95eb0c87f144851cd65048c3e0bc (patch) | |
| tree | 75863cc33e53fef354777cb7b9f206736c805201 /src/netbase.cpp | |
| parent | Merge pull request #6859 (diff) | |
| download | discoin-a4e28b3d1e5c95eb0c87f144851cd65048c3e0bc.tar.xz discoin-a4e28b3d1e5c95eb0c87f144851cd65048c3e0bc.zip | |
Set TCP_NODELAY on P2P sockets.
Nagle appears to be a significant contributor to latency now that the static
sleeps are gone. Most of our messages are relatively large compared to
IP + TCP so I do not expect this to create enormous overhead.
This may also reduce traffic burstyness somewhat.
Diffstat (limited to 'src/netbase.cpp')
| -rw-r--r-- | src/netbase.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index c3d56d918..f5316965c 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -444,12 +444,19 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe if (hSocket == INVALID_SOCKET) return false; -#ifdef SO_NOSIGPIPE int set = 1; +#ifdef SO_NOSIGPIPE // Different way of disabling SIGPIPE on BSD setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); #endif + //Disable Nagle's algorithm +#ifdef WIN32 + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int)); +#else + setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int)); +#endif + // Set to non-blocking if (!SetSocketNonBlocking(hSocket, true)) return error("ConnectSocketDirectly: Setting socket to non-blocking failed, error %s\n", NetworkErrorString(WSAGetLastError())); |