summary refs log tree commit diff
path: root/local.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--local.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/local.c b/local.c
index 0a140e6..50e49d5 100644
--- a/local.c
+++ b/local.c
@@ -20,6 +20,7 @@
 #include <limits.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -218,6 +219,13 @@ struct tls *localAccept(int *fd, int bind) {
 	int error = setsockopt(*fd, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(yes));
 	if (error) err(EX_OSERR, "setsockopt");
 
+	error = setsockopt(*fd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));
+	if (error) err(EX_OSERR, "setsockopt");
+
+	int idle = 15 * 60;
+	error = setsockopt(*fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
+	if (error) err(EX_OSERR, "setsockopt");
+
 	struct tls *client;
 	error = tls_accept_socket(server, &client, *fd);
 	if (error) errx(EX_SOFTWARE, "tls_accept_socket: %s", tls_error(server));