runtime: Cannot set udpClient.ExclusiveAddressUse = false in macOS and Linux

I originally posted this as a comment to this closed issue: https://github.com/dotnet/corefx/issues/8552#issuecomment-243579967

Since the issue is somewhat different, I decided to open a new one.

I am implementing a Multicast application, which requires me to allow to bind multiple sockets to the same port on a machine. While working fine on windows 10 setting udpClient.ExclusiveAddressUse = false fails for me on Linux and macOS with a SocketErrorCode 45 (Operation Not Supported) and an HResult of 0x80004005, which translates to “E_FAIL” or “Unspecified Error” as per this listing: https://msdn.microsoft.com/en-us/library/cc704587.aspx

I am testing on Windows 10 and macOS using the latest version of everything.

On Windows 10 I have to use: udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); for it to work. Using only udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false); doesn’t do a thing on windows and I receive an error.

On macOS I receive an error as follows, when using: udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false); Error:

System.Net.Sockets.SocketException : Operation not supported at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent) at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue) at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Boolean optionValue)

While using: udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); on macOS does not throw and exception, but does not work for me either.

The property udpClient.ExclusiveAddressUse behaves accordingly, in that it is working on Windows 10 and fails on macOS.

Is there anything I am missing or doing wrong here?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

I seem to be getting this exception still on .NET Core 2?