Unix: fix UDP ReuseAddress with non .NET Core UDP clients (dotnet/corefx#32046)
authorTom Deseyn <tom.deseyn@gmail.com>
Tue, 9 Oct 2018 11:17:06 +0000 (13:17 +0200)
committerStephen Toub <stoub@microsoft.com>
Tue, 9 Oct 2018 11:17:06 +0000 (07:17 -0400)
commit6fbecaa314b04fff56c7f584456e3db45a6f4be0
tree127d60ceec936a2009049f37257248af709d6bbf
parenta889202aca81c298c807f7e131b5910824bd19f9
Unix: fix UDP ReuseAddress with non .NET Core UDP clients (dotnet/corefx#32046)

* Unix: fix UDP ReuseAddress with non .NET Core UDP clients

.NET Core sets SO_REUSEPORT to enable reusing the address with other
sockets. This works when the other sockets also set SO_REUSEPORT.

SO_REUSEADDR can also be used for this. When one application uses
SO_REUSEADDR and another uses SO_REUSEPORT, the second application
will fail to bind.

To implement SocketOptionName.ReuseAddress we need to set both options.
This enables sharing with applications that set SO_REUSEPORT,
SO_REUSEADDR or both.

* Fix comment

* wording: share -> reuse

* Add test

* Fix test on mac

* Move DllImport to separate file

* Add separate csproj Configurations for Windows and Unix

* Add Windows and Unix to Configurations.props

Commit migrated from https://github.com/dotnet/corefx/commit/0ec9c9d7caac1ac378e2135620bf2f8b80e6ed86
src/libraries/Native/Unix/System.Native/pal_networking.c
src/libraries/System.Net.Sockets/tests/FunctionalTests/Configurations.props
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.Unix.cs [new file with mode: 0644]
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.Windows.cs [new file with mode: 0644]
src/libraries/System.Net.Sockets/tests/FunctionalTests/SocketOptionNameTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj