From 43ac86751249e9c5c62ac8235f3b12e40d44cdcb Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 30 Oct 2014 20:54:23 +0000 Subject: [PATCH] Stop Mono 3.2.8 from binding a UDP socket to a port already in use. At least on Mono 3.2.8 (but not under Windows), one can bind multiple UDP sockets to the same port by default. Different simulators cannot demultiplex each other's messages, so a set of confusing non-obvious errors arise if this occurs. This change prevents such multiple binding. --- OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 5323d5aeb7..94300f846b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -168,6 +168,12 @@ namespace OpenMetaverse m_log.Debug("[UDPBASE]: SIO_UDP_CONNRESET flag not supported on this platform, ignoring"); } + // On at least Mono 3.2.8, multiple UDP sockets can bind to the same port by default. At the moment + // we never want two regions to listen on the same port as they cannot demultiplex each other's messages, + // leading to a confusing bug. + // By default, Windows does not allow two sockets to bind to the same port. + m_udpSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, false); + if (recvBufferSize != 0) m_udpSocket.ReceiveBufferSize = recvBufferSize;