From a5aec70c18b0888aa5310f055e1365603cd68568 Mon Sep 17 00:00:00 2001 From: Quinton Miller Date: Thu, 20 Apr 2023 23:00:28 +0800 Subject: [PATCH] Fix `TCPSocket#tcp_keepalive_idle` on Windows --- spec/std/socket/tcp_socket_spec.cr | 2 +- src/crystal/system/win32/socket.cr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/std/socket/tcp_socket_spec.cr b/spec/std/socket/tcp_socket_spec.cr index 95c6f3967a61..9f06b4382323 100644 --- a/spec/std/socket/tcp_socket_spec.cr +++ b/spec/std/socket/tcp_socket_spec.cr @@ -128,7 +128,7 @@ describe TCPSocket, tags: "network" do end end - pending_win32 "settings" do + it "settings" do port = unused_local_port TCPServer.open("::", port) do |server| diff --git a/src/crystal/system/win32/socket.cr b/src/crystal/system/win32/socket.cr index dc830a0e5661..dbbb8ff59764 100644 --- a/src/crystal/system/win32/socket.cr +++ b/src/crystal/system/win32/socket.cr @@ -407,11 +407,11 @@ module Crystal::System::Socket end private def system_tcp_keepalive_idle - getsockopt LibC::SO_KEEPALIVE, 0, level: ::Socket::Protocol::TCP + getsockopt LibC::TCP_KEEPIDLE, 0, level: ::Socket::Protocol::TCP end private def system_tcp_keepalive_idle=(val : Int) - setsockopt LibC::SO_KEEPALIVE, val, level: ::Socket::Protocol::TCP + setsockopt LibC::TCP_KEEPIDLE, val, level: ::Socket::Protocol::TCP val end