-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: Initialize networking on Windows
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
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//! https://github.com/smol-rs/async-io/issues/182 | ||
|
||
use async_io::Async; | ||
use std::net::{TcpStream, ToSocketAddrs}; | ||
|
||
#[test] | ||
fn networking_initialized() { | ||
let address = match ToSocketAddrs::to_socket_addrs(&("google.com", 80)) { | ||
Ok(mut addrs) => addrs.next().unwrap(), | ||
Err(err) => { | ||
eprintln!("Got error {err} when looking up google.com, exiting test early."); | ||
return; | ||
} | ||
}; | ||
async_io::block_on(async move { | ||
let _ = Async::<TcpStream>::connect(address).await.unwrap(); | ||
}); | ||
} |