summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util.c b/util.c
index 4a2f1ad..7ca29c7 100644
--- a/util.c
+++ b/util.c
@@ -71,7 +71,7 @@ char *addr2string(struct sockaddr *addr, socklen_t len) {
int bindport(int type, char *port) {
struct addrinfo hints, *res0, *res;
- int s;
+ int s, one = 1;
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = type;
@@ -85,6 +85,7 @@ int bindport(int type, char *port) {
for (res = res0; res; res = res->ai_next) {
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (s >= 0) {
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
if (bind(s, res->ai_addr, res->ai_addrlen) == 0)
break;
close(s);