-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Why is SO_REUSEADDR disabled for Windows? #65
Comments
On 22/02/14 17:43, the mail apparently from MacGritsch included:
I'm reliant on Windows users to send patches, I don't use it. From the comment it looks like I or somebody else found it made trouble If it works properly now (or always did...) then fine --> -Andy
|
Hi, http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621%28v=vs.85%29.aspx "Once the second socket has successfully bound, the behavior for all sockets bound to that port is indeterminate. For example, if all of the sockets on the same port provide TCP service, any incoming TCP connection requests over the port cannot be guaranteed to be handled by the correct socket — the behavior is non-deterministic" On linux although this flag is enabled, the server will not be able to start twice and fail with "ERROR on binding to port ...", which in my opinion is the intended behaviour. But on windows the server will start twice and as stated on the website of microsoft, |
ok, but how to solve then the problem that you can not listen to the same port if the old service crashed? |
I've removed the REUSE for windows and tried it, but I wasn't able to reproduce this problem. Could you please give me some information on how I can reproduce such a crash? --- EDIT I just had a look at the Apache HTTPD project and how they handle this:
(Source: http://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x/server/listen.c) It looks like they only enable the REUSE on linux, but not on windows. |
Hi, been researching this intently, for another reason. |
Well if it makes trouble and is happy without it, provide a patch to disable ifdef WIN32... all the windows stuff is contributed. The thing is if another windows guy says that patch makes trouble I can't judge it since I don't use it. |
Hi,
also under Windows SO_REUSEADDR is needed, otherwise you can not bind if you are restarting a crashed service.
http://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
The text was updated successfully, but these errors were encountered: