summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compat.h4
-rw-r--r--local.c8
2 files changed, 12 insertions, 0 deletions
diff --git a/compat.h b/compat.h
index d471a8f..01ef10c 100644
--- a/compat.h
+++ b/compat.h
@@ -35,3 +35,7 @@ uint32_t arc4random_uniform(uint32_t upper_bound);
 #ifndef SIGINFO
 #define SIGINFO SIGUSR2
 #endif
+
+#ifdef __APPLE__
+#define TCP_KEEPIDLE TCP_KEEPALIVE
+#endif
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));
p;follow=1'>Make dtch one command, add sinkingJune McEnroe 2019-08-03Add ImagoJune McEnroe 2019-07-29Add KindredJune McEnroe 2019-07-27Clean up home filesJune McEnroe 2019-07-27Fix shell script style in ~/.local/binJune McEnroe 2019-07-27Shell script style passJune McEnroe 2019-07-27Add c11.pdfJune McEnroe 2019-07-27Move pdf script to MakefileJune McEnroe 2019-07-27Update macOS neovim to 0.3.8June McEnroe Which somehow still doesn't include my man fix. 2019-07-27Rewrite port makefiles consistentlyJune McEnroe 2019-07-27Rewrite Makefile once more with more organizationJune McEnroe 2019-07-27Reference png.h in bin.7June McEnroe 2019-07-27Revert "Use scheme to style HTMLs"June McEnroe This reverts commit 4b7d5161a30645b0a23691687ef1aafdda62d3bb. I don't know why but I don't like it. 2019-07-27Remove scheme text linkJune McEnroe No standard base64 encoder so no way to maintain it. 2019-07-26Update Dark.terminalJune McEnroe Why are the blobs so much bigger now? 2019-07-26Lighten dark whiteJune McEnroe 2019-07-25Add png.3 man pageJune McEnroe 2019-07-25Use scheme to style HTMLsJune McEnroe 2019-07-25Don't match comments in strings in makeJune McEnroe 2019-07-25Generate index.html with links from bin.7June McEnroe 2019-07-24Warn when date has changedJune McEnroe 2019-07-24Add whenJune McEnroe When? Now. 2019-07-24Remove histedit from bitJune McEnroe