karyon_core/async_runtime/
net.rs1use std::{io, net::SocketAddr as InetSocketAddr};
2
3#[cfg(target_family = "unix")]
4pub use std::os::unix::net::SocketAddr;
5
6#[cfg(all(feature = "smol", target_family = "unix"))]
7pub use smol::net::unix::{SocketAddr as UnixSocketAddr, UnixListener, UnixStream};
8#[cfg(feature = "smol")]
9pub use smol::net::{TcpListener, TcpStream, UdpSocket};
10
11#[cfg(feature = "tokio")]
12pub use tokio::net::{TcpListener, TcpStream, UdpSocket};
13#[cfg(all(feature = "tokio", target_family = "unix"))]
14pub use tokio::net::{UnixListener, UnixStream, unix::SocketAddr as UnixSocketAddr};
15
16pub async fn lookup_host(host: &str, port: u16) -> io::Result<Vec<InetSocketAddr>> {
19 #[cfg(feature = "smol")]
20 let result = smol::net::resolve((host, port)).await;
21 #[cfg(feature = "tokio")]
22 let result = tokio::net::lookup_host((host, port))
23 .await
24 .map(|addrs| addrs.collect());
25
26 result
27}