summaryrefslogtreecommitdiff
path: root/zen/socket.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-05-10 11:21:56 -0400
committerB. Stack <bgstack15@gmail.com>2024-05-10 11:21:56 -0400
commit7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7 (patch)
tree3ed84995318afbd82d5d98a2ba044f9ba58b57c6 /zen/socket.h
parentadd upstream 13.5 (diff)
downloadFreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.tar.gz
FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.tar.bz2
FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.zip
add upstream 13.613.6
Diffstat (limited to 'zen/socket.h')
-rw-r--r--zen/socket.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/zen/socket.h b/zen/socket.h
index c2fdb145..0a311d01 100644
--- a/zen/socket.h
+++ b/zen/socket.h
@@ -10,6 +10,7 @@
#include "sys_error.h"
#include <unistd.h> //close
#include <sys/socket.h>
+ #include <netinet/tcp.h> //TCP_NODELAY
#include <netdb.h> //getaddrinfo
@@ -102,7 +103,6 @@ public:
THROW_LAST_SYS_ERROR_WSA("socket");
ZEN_ON_SCOPE_FAIL(closeSocket(testSocket));
-
if (::connect(testSocket, ai.ai_addr, static_cast<int>(ai.ai_addrlen)) != 0) //0 or SOCKET_ERROR(-1)
{
if (errno != EINPROGRESS)
@@ -141,6 +141,16 @@ public:
}
setNonBlocking(testSocket, false); //throw SysError
+ //-----------------------------------------------------------
+
+ int noDelay = 1; //disable Nagle algorithm: https://brooker.co.za/blog/2024/05/09/nagle.html
+ //e.g. test case "website sync": 23% shorter comparison time!
+ if (::setsockopt(testSocket, //_In_ SOCKET s
+ IPPROTO_TCP, //_In_ int level
+ TCP_NODELAY, //_In_ int optname
+ reinterpret_cast<char*>(&noDelay), //_In_ const char* optval
+ sizeof(noDelay)) != 0) //_In_ int optlen
+ THROW_LAST_SYS_ERROR_WSA("setsockopt(TCP_NODELAY)");
return testSocket;
};
bgstack15