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;