Enable SO_REUSEADDR again

pull/30/head
Andri Yngvason 2020-04-06 18:29:17 +00:00
parent 11a73c5cb0
commit 048b796ff5
1 changed files with 5 additions and 0 deletions

View File

@ -796,9 +796,14 @@ int bind_address(const char* name, int port)
if (fd < 0)
continue;
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(int)) < 0)
goto failure;
if (bind(fd, p->ai_addr, p->ai_addrlen) == 0)
break;
failure:
close(fd);
fd = -1;
}