-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gen_udp:open/2 does not set {reuseaddr, true} on Windows 10 #4819
Comments
After some searching on the net, I found that this (REUSEADDR) seems to have issues on windows. I also found the following comment: "I understand REUSE is popular under *nix because it prevents re-binding process restart errors |
The same applies to otp/erts/emulator/drivers/common/inet_drv.c Lines 6635 to 6637 in d646fa3
|
So... it's more like an intended feature then a bug😅 |
I think it should be "feature" in this case... |
"Bjorn says", priceless 😄 |
I don't remember all the details, but IIRC reuseaddr means something very different (and dangerous, of course) on Windows... |
On Tue, May 25, 2021 at 7:26 PM Maria Scott ***@***.***> wrote:
"Bjorn says", priceless 😄
I think that comment was written by Tony Rogvall (https://github.com/tonyrog).
The backstory was that at the time the Erlang distribution had its own
driver and there was a separate port program for applications that wanted
to use TCP and UDP. Tony was working on a new driver called the inet_driver
that could serve both purposes.
At that time, I was working with the Windows 95/NT build of Erlang. In the
socket code for Windows, we had removed the SO_REUSEADDR option, because we
had noticed that it would cause unsafe reuse of listen ports.
When Tony showed me code for the inet_driver, I saw that it used
SO_REUSEADDR on all platforms and I told him that he would have to take it
out for Windows.
He did.
|
Added a PR, which solves this by introducing a new option; 'win_reuseaddr' which |
This option, 'reuseaddr', will be handled the same way on Windows as on other OSes. As of 25.0! |
@ziopio As of OTP 26 the |
Describe the bug
On Windows 10 64-bit, when i try to open an UDP port with option {reuseaddr, true} the option is not applied.
The resulting socket owns the port exclusively. This makes it impossible to open multiple sockets on the same port.
The bug DOES NOT occur on an OTP linux installation executing through WSL.
To Reproduce (OTP 23.3 Eshell V11.2, Windows 10 64-bit )
1> {_,S} = gen_udp:open(0,[{reuseaddr, true}]).
{ok,#Port<0.4>}
2> inet:getopts(S,[reuseaddr]).
{ok,[{reuseaddr,false}]}
Expected behavior (OTP 22 Eshell V10.6.4, Ubuntu 20.04 on WSL )
1> {_,S} = gen_udp:open(0,[{reuseaddr, true}]).
{ok,#Port<0.4>}
2> inet:getopts(S,[reuseaddr]).
{ok,[{reuseaddr,true}]}
Affected versions
Erlang/OTP 23.3 with Eshell V 11.2, 64-bit binary installation on Windows 10
Additional context
I my case i am implementing the RTPS protocol by ObjectManagmentGroup in Erlang. The p2p discovery requires multiple participants to listen to the same port for UDP multicast packets. This bug prevents me to start more than one node on my system.
The text was updated successfully, but these errors were encountered: