[Mono-dev] In Mono 3.2.8 but not with Microsoft .NET Framework 4 can bind to same UDP port twice by default
jjustincc at googlemail.com
Thu Oct 30 20:26:05 UTC 2014
Hi folks. In at least Mono 3.2.8 (3.2.8+dfsg-4ubuntu1), by default one can bind multiple UDP sockets to the same port
without error. Under at least Microsoft .NET Framework 4 on Windows, the following error is generated instead
Unhandled Exception: System.Net.Sockets.SocketException: Only one usage of each
socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at UdpSamePort.Main(String args)
This gist  has a small program demonstrating this behaviour. Explicitly setting SocketOptionName.ReuseAddress to
false on the socket prevents Mono from binding the second socket to the same address.
Is this expected behaviour for Mono (Linux?) compared to Windows? I haven't checked this behaviour yet under later (or
earlier) Mono versions.
Justin Clark-Casey (justincc)
More information about the Mono-devel-list