From 61b5b299f0ac4f0efbe11a45716e06a9c35f37b7 Mon Sep 17 00:00:00 2001 From: Michael Grunder Date: Sat, 3 Sep 2022 12:39:57 -0700 Subject: Use a windows specific keepalive function. (#1104) Use a windows specific keepalive function. While it is possible to toggle `TCP_KEEPALIVE` in windows via setsockopt, you have to use `WSAIoctl` to set the interval. Since `WSAIoctl` can actually do all of this in one call (toggle the option, and set the corresponding interval), just use that in Windows and avoid the call to `setsockopt` alltogether. Fixes: #1100 --- sockcompat.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sockcompat.h') diff --git a/sockcompat.h b/sockcompat.h index 85810e8..1aaf23f 100644 --- a/sockcompat.h +++ b/sockcompat.h @@ -50,6 +50,7 @@ #include #include #include +#include #ifdef _MSC_VER typedef long long ssize_t; @@ -71,6 +72,8 @@ ssize_t win32_send(SOCKET sockfd, const void *buf, size_t len, int flags); typedef ULONG nfds_t; int win32_poll(struct pollfd *fds, nfds_t nfds, int timeout); +int win32_redisKeepAlive(SOCKET sockfd, int interval_ms); + #ifndef REDIS_SOCKCOMPAT_IMPLEMENTATION #define getaddrinfo(node, service, hints, res) win32_getaddrinfo(node, service, hints, res) #undef gai_strerror -- cgit v1.2.3