Skip to content
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

[WIP] Stop setting SO_REUSEADDR to fix Port Forwarding #654

Open
wants to merge 2 commits into
base: latestw_all
Choose a base branch
from

Conversation

vthiebaut10
Copy link
Collaborator

@vthiebaut10 vthiebaut10 commented Jan 17, 2023

Fix: PowerShell/Win32-OpenSSH#1968

PR Summary

SO_REUSEADDR socket option means different things on Windows and *nix systems.
On Windows, that option allows sockets to forcibly bind to ports in use by other sockets. The behavior for all sockets once the second socket is bound to the port is indeterminate. (See: https://learn.microsoft.com/en-us/windows/win32/winsock/using-so-reuseaddr-and-so-exclusiveaddruse#using-so_reuseaddr)

On *nix systems, the SO_REUSEADDR is used to address edge cases that might occur after socket termination. It allows the socket to be reused while it is on TIME_WAIT state. It still returns "Address already in use" error if the socket is being used while in any other state. (See: https://stackoverflow.com/questions/3229860/what-is-the-meaning-of-so-reuseaddr-setsockopt-option-linux)

Supposedly, Windows doesn't have the issue of preventing the reutilization of sockets during TIME_WAIT (according to this discussion: warmcat/libwebsockets#65 (comment)), so there should be no value for us to use the SO_REUSEADDR when creating sockets.

@vthiebaut10 vthiebaut10 changed the title Stop setting SO_REUSEADDR to fix Port Forwarding [WIP] Stop setting SO_REUSEADDR to fix Port Forwarding Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant