diff options
author | June McEnroe <june@causal.agency> | 2019-10-27 16:53:25 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-10-27 16:53:25 -0400 |
commit | f2555e841105a7ead9ed4794fe2b3d185ad7f880 (patch) | |
tree | 0abd1287ff5fdd3f15f77d9d1299be23e5a2e1db | |
parent | Output ring info on SIGINFO (diff) | |
download | pounce-f2555e841105a7ead9ed4794fe2b3d185ad7f880.tar.gz pounce-f2555e841105a7ead9ed4794fe2b3d185ad7f880.zip |
Set SO_REUSEADDR on binds
-rw-r--r-- | listen.c | 4 |
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); |