std/sys/net/connection/
mod.rs1cfg_select! {
2 any(
3 all(target_family = "unix", not(target_os = "l4re")),
4 target_os = "windows",
5 target_os = "hermit",
6 all(target_os = "wasi", any(target_env = "p2", target_env = "p3")),
7 target_os = "solid_asp3",
8 ) => {
9 mod socket;
10 pub use socket::*;
11 }
12 all(target_vendor = "fortanix", target_env = "sgx") => {
13 mod sgx;
14 pub use sgx::*;
15 }
16 all(target_os = "wasi", target_env = "p1") => {
17 mod wasip1;
18 pub use wasip1::*;
19 }
20 target_os = "motor" => {
21 mod motor;
22 pub use motor::*;
23 }
24 target_os = "xous" => {
25 mod xous;
26 pub use xous::*;
27 }
28 target_os = "uefi" => {
29 mod uefi;
30 pub use uefi::*;
31 }
32 _ => {
33 mod unsupported;
34 pub use unsupported::*;
35 }
36}
37
38#[cfg_attr(
39 not(any(target_os = "linux", target_os = "windows")),
41 allow(dead_code)
42)]
43fn each_addr<A: crate::net::ToSocketAddrs, F, T>(addr: A, mut f: F) -> crate::io::Result<T>
44where
45 F: FnMut(&crate::net::SocketAddr) -> crate::io::Result<T>,
46{
47 use crate::io::Error;
48
49 let mut last_err = None;
50 for addr in addr.to_socket_addrs()? {
51 match f(&addr) {
52 Ok(l) => return Ok(l),
53 Err(e) => last_err = Some(e),
54 }
55 }
56
57 match last_err {
58 Some(err) => Err(err),
59 None => Err(Error::NO_ADDRESSES),
60 }
61}