From 7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Fri, 10 May 2024 11:21:56 -0400 Subject: add upstream 13.6 --- zen/socket.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'zen/socket.h') 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 //close #include + #include //TCP_NODELAY #include //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(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(&noDelay), //_In_ const char* optval + sizeof(noDelay)) != 0) //_In_ int optlen + THROW_LAST_SYS_ERROR_WSA("setsockopt(TCP_NODELAY)"); return testSocket; }; -- cgit