use std::io; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
#[tokio::test] asyncfn lookup_socket_addr() { let addr: SocketAddr = "127.0.0.1:8000".parse().unwrap();
let actual = assert_ok!(net::lookup_host(addr).await).collect::<Vec<_>>();
assert_eq!(vec![addr], actual);
}
#[tokio::test] asyncfn lookup_str_socket_addr() { let addr: SocketAddr = "127.0.0.1:8000".parse().unwrap();
let actual = assert_ok!(net::lookup_host("127.0.0.1:8000").await).collect::<Vec<_>>();
assert_eq!(vec![addr], actual);
}
// Note that WASIp2 _does_ support asynchronous name lookups without requiring a // worker thread, so this test could be ungated for WASI if/when that's // implemented. #[cfg_attr(
target_os = "wasi",
ignore = "net::lookup_host requires multithreading, which WASI does not yet support"
)] #[tokio::test] #[cfg_attr(miri, ignore)] // No `getaddrinfo` in miri. asyncfn resolve_dns() -> io::Result<()> { letmut hosts = net::lookup_host("localhost:3000").await?; let host = hosts.next().unwrap();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.