From a2d96f18314c2211505b95a62ab976afcb5c3f69 Mon Sep 17 00:00:00 2001 From: Boris-Barboris Date: Mon, 2 Apr 2018 18:06:00 +0300 Subject: [PATCH] fix setKeepAliveParams on Windows --- source/eventcore/drivers/winapi/sockets.d | 5 ++++- source/eventcore/internal/win32.d | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/eventcore/drivers/winapi/sockets.d b/source/eventcore/drivers/winapi/sockets.d index 4b59e32..fb31517 100644 --- a/source/eventcore/drivers/winapi/sockets.d +++ b/source/eventcore/drivers/winapi/sockets.d @@ -8,6 +8,8 @@ import eventcore.internal.win32; import eventcore.internal.utils : AlgebraicChoppedVector, print, nogc_assert; import std.socket : Address; +import core.time: Duration; + private enum WM_USER_SOCKET = WM_USER + 1; @@ -225,7 +227,8 @@ final class WinAPIEventDriverSockets : EventDriverSockets { { tcp_keepalive opts = tcp_keepalive(1, cast(ulong) idle.total!"msecs"(), cast(ulong) interval.total!"msecs"); - int result = WSAIoctl(socket, SIO_KEEPALIVE_VALS, &opts, tcp_keepalive.sizeof, null, 0, null, null); + int result = WSAIoctl(socket, SIO_KEEPALIVE_VALS, &opts, cast(uint) tcp_keepalive.sizeof, + null, 0, null, null, null); if (result != 0) { print("WSAIoctl SIO_KEEPALIVE_VALS returned %d", result); diff --git a/source/eventcore/internal/win32.d b/source/eventcore/internal/win32.d index 69c99a3..2662502 100644 --- a/source/eventcore/internal/win32.d +++ b/source/eventcore/internal/win32.d @@ -112,18 +112,18 @@ struct tcp_keepalive { }; // https://gist.github.com/piscisaureus/906386#file-winsock2-h-L1099 -enum : ulong { +enum : DWORD { IOC_VENDOR = 0x18000000, IOC_OUT = 0x40000000, IOC_IN = 0x80000000 } -ulong _WSAIOW(ulong x, ulong y) pure @safe +DWORD _WSAIOW(DWORD x, DWORD y) pure @safe { return IOC_IN | x | y; } -enum : ulong { +enum : DWORD { SIO_KEEPALIVE_VALS = _WSAIOW(IOC_VENDOR, 4) }