From c0792e54052bd3222c3b00e45f7e81c87187504a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sat, 29 Oct 2011 02:00:04 +0200 Subject: [PATCH] Windows: the correct way to make TCP_KEEPALIVE work on MinGW --- src/win/tcp.c | 2 +- src/win/winsock.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/win/tcp.c b/src/win/tcp.c index 485d93da..662090d0 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -71,7 +71,7 @@ static int uv__tcp_keepalive(uv_tcp_t* handle, SOCKET socket, int enable, unsign if (enable && setsockopt(socket, IPPROTO_TCP, - SO_KEEPALIVE, + TCP_KEEPALIVE, (const char*)&delay, sizeof delay) == -1) { uv__set_sys_error(handle->loop, errno); diff --git a/src/win/winsock.h b/src/win/winsock.h index beee0321..433ce476 100644 --- a/src/win/winsock.h +++ b/src/win/winsock.h @@ -37,6 +37,10 @@ # define SO_UPDATE_CONNECT_CONTEXT 0x7010 #endif +#ifndef TCP_KEEPALIVE +# define TCP_KEEPALIVE 3 +#endif + #ifndef IPV6_V6ONLY #define IPV6_V6ONLY 27 #endif