Skip to main content

connect_bounded

Function connect_bounded 

pub fn connect_bounded<A>(
    addr: A,
    timeout: Duration,
) -> Result<TcpStream, Error>
where A: ToSocketAddrs,
Expand description

Resolve addr and connect with a bounded per-resolved-address timeout, returning the first address that connects. A drop-in for TcpStream::connect (same io::Result<TcpStream> shape) that never blocks past timeout per address, so a cast to an unreachable endpoint fails fast instead of hanging on the OS default connect timeout.

ยงErrors

The last connect io::Error when no resolved address connects within timeout, or an InvalidInput error when addr resolves to no addresses.