From 3de2b56557c80b310341c423492bd8ba895c1abe Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 26 Apr 2018 13:53:40 -0700 Subject: fixes #105 Want NNG_OPT_TCP_NODELAY option fixes #106 TCP keepalive tuning --- src/platform/windows/win_tcp.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/platform/windows') diff --git a/src/platform/windows/win_tcp.c b/src/platform/windows/win_tcp.c index 17f7845d..4d7d6027 100644 --- a/src/platform/windows/win_tcp.c +++ b/src/platform/windows/win_tcp.c @@ -243,6 +243,30 @@ nni_plat_tcp_pipe_sockname(nni_plat_tcp_pipe *pipe, nni_sockaddr *sa) return (0); } +int +nni_plat_tcp_pipe_set_nodelay(nni_plat_tcp_pipe *pipe, bool val) +{ + BOOL b; + b = val ? TRUE : FALSE; + if (setsockopt(pipe->s, IPPROTO_TCP, TCP_NODELAY, (void *) &b, + sizeof(b)) != 0) { + return (nni_win_error(WSAGetLastError())); + } + return (0); +} + +int +nni_plat_tcp_pipe_set_keepalive(nni_plat_tcp_pipe *pipe, bool val) +{ + BOOL b; + b = val ? TRUE : FALSE; + if (setsockopt(pipe->s, SOL_SOCKET, SO_KEEPALIVE, (void *) &b, + sizeof(b)) != 0) { + return (nni_win_error(WSAGetLastError())); + } + return (0); +} + void nni_plat_tcp_pipe_fini(nni_plat_tcp_pipe *pipe) { -- cgit v1.2.3-70-g09d2