From a16215e099d7a04807b260034d6ad4a8b80fa842 Mon Sep 17 00:00:00 2001 From: angt Date: Wed, 21 Oct 2015 18:14:53 +0200 Subject: [PATCH] Set SO_REUSEADDR on listener --- glorytun.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/glorytun.c b/glorytun.c index 5628579..38e8253 100644 --- a/glorytun.c +++ b/glorytun.c @@ -45,7 +45,13 @@ static int gt_open_sock (char *host, char *port, int listener) int ret; if (listener) { + const int val = 1; + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val))==-1) + printf("setsockopt: %m\n"); + ret = bind(fd, ai->ai_addr, ai->ai_addrlen); + if (!ret) ret = listen(fd, 1); } else {