From 1cf28be647f20370de7ddb5d8c60b2753d2e5869 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Wed, 28 Nov 2018 19:39:11 +0000 Subject: [PATCH] Add SO_REUSEADDR to the UDP sockets. See if it makes any difference. --- rtp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rtp.c b/rtp.c index 1f908b0e..464bc303 100644 --- a/rtp.c +++ b/rtp.c @@ -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;