1use std::net::SocketAddr;
7use std::{io, iter};
8
9use crate::world::World;
10use crate::ToSocketAddrs;
11
12pub mod tcp;
13pub use tcp::{listener::TcpListener, stream::TcpStream};
14
15pub(crate) mod udp;
16pub use udp::UdpSocket;
17
18pub async fn lookup_host<T>(host: T) -> io::Result<impl Iterator<Item = SocketAddr>>
22where
23 T: ToSocketAddrs,
24{
25 let addr = World::current(|world| host.to_socket_addr(&world.dns))?;
26 Ok(iter::once(addr))
27}
28
29#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
30pub(crate) struct SocketPair {
31 pub(crate) local: SocketAddr,
32 pub(crate) remote: SocketAddr,
33}
34
35impl SocketPair {
36 pub(crate) fn new(local: SocketAddr, remote: SocketAddr) -> SocketPair {
37 assert_ne!(local, remote);
38 SocketPair { local, remote }
39 }
40}