[Mono-dev] In Mono 3.2.8 but not with Microsoft .NET Framework 4 can bind to same UDP port twice by default

Justin Clark-Casey 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
socketAddress)
    at System.Net.Sockets.Socket.Bind(EndPoint localEP)
    at UdpSamePort.Main(String[] args)

This gist [1] 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.

[1] https://gist.github.com/justincc/c431165a6d7194169328

Regards,

-- 
Justin Clark-Casey (justincc)
OSVW Consulting
http://justincc.org
http://twitter.com/justincc


More information about the Mono-devel-list mailing list