summary refs log tree commit diff
path: root/listen.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-10-27 16:53:25 -0400
committerJune McEnroe <june@causal.agency>2019-10-27 16:53:25 -0400
commitf2555e841105a7ead9ed4794fe2b3d185ad7f880 (patch)
tree0abd1287ff5fdd3f15f77d9d1299be23e5a2e1db /listen.c
parentOutput ring info on SIGINFO (diff)
downloadpounce-f2555e841105a7ead9ed4794fe2b3d185ad7f880.tar.gz
pounce-f2555e841105a7ead9ed4794fe2b3d185ad7f880.zip
Set SO_REUSEADDR on binds
Diffstat (limited to 'listen.c')
-rw-r--r--listen.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/listen.c b/listen.c
index 952d798..1797acf 100644
--- a/listen.c
+++ b/listen.c
@@ -63,6 +63,10 @@ size_t listenBind(int fds[], size_t cap, const char *host, const char *port) {
 		fds[len] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
 		if (fds[len] < 0) err(EX_OSERR, "socket");
 
+		int yes = 1;
+		error = setsockopt(fds[len], SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
+		if (error) err(EX_OSERR, "setsockopt");
+
 		error = bind(fds[len], ai->ai_addr, ai->ai_addrlen);
 		if (error) {
 			warn("%s:%s", host, port);