wm: glendy

Download patch

ref: e762861df8b2fcdad4c4c37eda862a2616314d03
parent: 226cdb436fdb320ab5076ea04bb64a04b849c285
author: mkf <mkf@cloud9p.org>
date: Mon May 6 07:27:34 EDT 2024

srv: reuseaddr, so we don't have to wait for wait time to finish when restarting

--- a/srv.c
+++ b/srv.c
@@ -92,7 +92,7 @@
 int
 setuplistener(int portno)
 {
-	int sockfd;
+	int sockfd, option = 1;
 	struct sockaddr_in serv_addr;
 
 	sockfd = socket(AF_INET, SOCK_STREAM, 0);
@@ -102,7 +102,8 @@
 	memset(&serv_addr, 0, sizeof(serv_addr));
 	serv_addr.sin_family = AF_INET;	
 	serv_addr.sin_addr.s_addr = INADDR_ANY;	
-	serv_addr.sin_port = htons(portno);		
+	serv_addr.sin_port = htons(portno);	
+	setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
 
 	if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
 		error("ERROR binding listener socket.");