From d842ad65bbeb3c6163d6b799fc5d8bb93c5bf3b6 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 28 Feb 2016 23:03:18 -0800 Subject: [PATCH] More limits to damage done by write <-> write and disconnected hsots. --- adsbus/socket.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adsbus/socket.c b/adsbus/socket.c index b451e85..0c37ceb 100644 --- a/adsbus/socket.c +++ b/adsbus/socket.c @@ -39,6 +39,14 @@ void socket_send_init(int fd) { int optval = 128; // Lowest value that the kernel will accept res = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &optval, sizeof(optval)); assert(res == 0 || (res == -1 && errno == ENOTSOCK)); + + optval = 128; // Lowest value that the kernel will accept + res = setsockopt(fd, IPPROTO_TCP, TCP_WINDOW_CLAMP, &optval, sizeof(optval)); + assert(res == 0 || (res == -1 && errno == ENOTSOCK)); + + optval = 60000; // 60s + res = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &optval, sizeof(optval)); + assert(res == 0 || (res == -1 && errno == ENOTSOCK)); } void socket_receive_init(int fd) {