From c90a2f7a68e3d1054bceed8b67acb7bd0af8d14f Mon Sep 17 00:00:00 2001 From: cflip Date: Tue, 6 Jun 2023 17:23:50 -0600 Subject: Ignore SIGPIPE signals when writing to a closed socket --- net.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'net.c') diff --git a/net.c b/net.c index bbf80d1..84d713b 100644 --- a/net.c +++ b/net.c @@ -23,9 +23,11 @@ int net_init_server(int port) return -1; } - /* Allow the port to be reused, prevents errors when quickly starting - * and restarting the server. */ - /* TODO: Also use SO_REUSEPORT? */ + /* + * Set SO_REUSEADDR to allow the port to be reused, preventing errors + * when quickly starting and restarting the server. SO_REUSEPORT and + * SO_NOSIGPIPE would also be nice, but they are not supported on Linux. + */ setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopts, sizeof(int)); memset(&addr, 0, sizeof(struct sockaddr_in)); -- cgit v1.2.3