diff options
author | Thomas Snider <tjps636@gmail.com> | 2017-03-22 22:02:02 -0700 |
---|---|---|
committer | Thomas Snider <tjps636@gmail.com> | 2017-04-05 11:31:43 -0700 |
commit | ad415bc16afdb4fdb6d619624762f1324751a824 (patch) | |
tree | f36dd6aa64fa7e498e60195008922e3a9c883f0c /src/netbase.cpp | |
parent | 02d64bd929c9663ba38e96721c6dbd89972d043d (diff) |
[net] Added SetSocketNoDelay() utility function
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index 0f02e93e46..ead2f4db7d 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -428,18 +428,14 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe if (hSocket == INVALID_SOCKET) return false; - int set = 1; #ifdef SO_NOSIGPIPE + int set = 1; // 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 + SetSocketNoDelay(hSocket); // Set to non-blocking if (!SetSocketNonBlocking(hSocket, true)) @@ -728,6 +724,13 @@ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking) return true; } +bool SetSocketNoDelay(SOCKET& hSocket) +{ + int set = 1; + int rc = setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int)); + return rc == 0; +} + void InterruptSocks5(bool interrupt) { interruptSocks5Recv = interrupt; |