-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
TcpListener::bind broken under Windows 7 #26543
Labels
O-windows
Operating system: Windows
Comments
Might be similar to #26518. |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Jul 1, 2015
This was added after Windows 7 SP1, so it's not always available. Instead use the `SetHandleInformation` function to flag a socket as not inheritable. This is not atomic with respect to creating new processes, but it mirrors what Unix does with respect to possibly using the atomic option in the future. Closes rust-lang#26543
bors
added a commit
that referenced
this issue
Jul 1, 2015
This was added after Windows 7 SP1, so it's not always available. Instead use the `SetHandleInformation` function to flag a socket as not inheritable. This is not atomic with respect to creating new processes, but it mirrors what Unix does with respect to possibly using the atomic option in the future. Closes #26543
bors
added a commit
that referenced
this issue
Dec 6, 2019
std:win: avoid WSA_FLAG_NO_INHERIT flag and don't use SetHandleInformation on UWP This flag is not supported on Windows 7 before SP1, and on windows server 2008 SP2. This breaks Socket creation & duplication. This was fixed in a previous PR. cc #26658 This PR: cc #60260 reuses this flag to support UWP, and makes an attempt to handle the potential error. This version still fails to create a socket, as the error returned by WSA on this case is WSAEINVAL (invalid argument). and not WSAEPROTOTYPE. MSDN page for WSASocketW (that states the platform support for WSA_FLAG_NO_HANDLE_INHERIT): https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw CC #26543 CC #26518
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Creating a TCP listener socket will result in error under Windows 7. Minimal test case:
This will produce an error with code 10041 (
WSAEPROTOTYPE
).This was tested on stable Rust (1.0.0).
After a bit digging, turns out this particular piece of code might be the cause of the breakage. According to the Winsock docs, The
WSA_FLAG_NO_HANDLE_INHERIT
flag is supported on at least Windows 7 SP1, so running on vanilla Windows 7 would not work and would apparently break your program.The text was updated successfully, but these errors were encountered: