Add SO_REUSEADDR to the UDP sockets. See if it makes any difference.

This commit is contained in:
Mike Brady
2018-11-28 19:39:11 +00:00
parent 22f3e3e318
commit 1cf28be647
+10
View File
@@ -858,6 +858,16 @@ static uint16_t bind_port(int ip_family, const char *self_ip_address, uint32_t s
int local_socket = socket(ip_family, SOCK_DGRAM, IPPROTO_UDP);
if (local_socket == -1)
die("Could not allocate a socket.");
int val = 1;
ret = setsockopt(local_socket, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
if (ret < 0) {
char errorstring[1024];
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
debug(1,"Error %d: \"%s\". Couldn't set SO_REUSEADDR");
}
SOCKADDR myaddr;
int tryCount = 0;
uint16_t desired_port;