From dbc6f70f192cfbb382b96bdfba047424dd34bb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 16 Mar 2025 10:09:33 +0800 Subject: [PATCH] Networking (Windows): fix libz loading; use TCP_FASTOPEN if available --- src/common/networking/networking_common.c | 8 +++++++- src/common/networking/networking_windows.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common/networking/networking_common.c b/src/common/networking/networking_common.c index 45e95b401..df04eb3f0 100644 --- a/src/common/networking/networking_common.c +++ b/src/common/networking/networking_common.c @@ -22,7 +22,13 @@ const char* ffNetworkingLoadZlibLibrary(void) if (!zlibData.inited) { zlibData.inited = true; - FF_LIBRARY_LOAD(zlib, "dlopen libz failed", "libz" FF_LIBRARY_EXTENSION, 2) + FF_LIBRARY_LOAD(zlib, "dlopen libz failed", + #ifdef _WIN32 + "zlib1" + #else + "libz" + #endif + FF_LIBRARY_EXTENSION, 2) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateInit2_) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflate) FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(zlib, zlibData, inflateEnd) diff --git a/src/common/networking/networking_windows.c b/src/common/networking/networking_windows.c index 92ce0375a..93ca13f6c 100644 --- a/src/common/networking/networking_windows.c +++ b/src/common/networking/networking_windows.c @@ -105,9 +105,9 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho return "socket() failed"; } + DWORD flag = 1; #ifdef TCP_NODELAY // Enable TCP_NODELAY to disable Nagle's algorithm - DWORD flag = 1; if (setsockopt(state->sockfd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag)) != 0) { FF_DEBUG("Failed to set TCP_NODELAY: %d", WSAGetLastError()); } else { @@ -115,6 +115,15 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho } #endif + #ifdef TCP_FASTOPEN + // Set TCP Fast Open + if (setsockopt(state->sockfd, IPPROTO_TCP, TCP_FASTOPEN, (char*)&flag, sizeof(flag)) != 0) { + FF_DEBUG("Failed to set TCP_FASTOPEN option: %d", WSAGetLastError()); + } else { + FF_DEBUG("Successfully set TCP_FASTOPEN option"); + } + #endif + // Set timeout if needed if (state->timeout > 0) { FF_DEBUG("Setting connection timeout: %u ms", state->timeout);