-
Notifications
You must be signed in to change notification settings - Fork 67
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
Async::<TcpStream>::connect fails on windows #182
Comments
Ah right. With This can be fixed by either calling that function or by creating and destroying a |
But rustix function is not in the api of async-io, so I think it should be called internally. Not by the user of the library. This problem affects smol, as you cannot connect to a socket on windows. This example in smol crate fails to run on windows: |
Yes. I'll accept a PR that creates a network socket internally in order to set up networking. If not I'll file one later. |
As far as I understand this: ""On Windows, it’s necessary to initialize the sockets subsystem before using sockets APIs" means that at least the function should be called once. So it can be called only once. I have no idea what can happen if it is called more than once. |
This commit adds a setup_networking function. On most platforms it does nothing. However, on Windows it calls `wsa_startup`. This ensures that all networking is set up before anything else is called. Closes #182 Signed-off-by: John Nunley <dev@notgull.net>
connect fails on windows with "Either the application has not called WSAStartup, or WSAStartup failed."
According to "https://docs.rs/rustix/0.38.30/x86_64-pc-windows-msvc/rustix/net/fn.wsa_startup.html"
pub fn wsa_startup() -> Result
"On Windows, it’s necessary to initialize the sockets subsystem before using sockets APIs. The function performs the necessary initialization."
Calling this function before trying to connect solves the problem.
The text was updated successfully, but these errors were encountered: