Function race_connect
pub async fn race_connect<S, C, F, Fut>(
candidates: S,
max_in_flight: usize,
dial: F,
) -> Result<(SocketAddr, C), Box<dyn Error + Sync + Send>>Available on crate feature
net only.Expand description
Race connection attempts over a stream of candidate SocketAddresses.
Pulls candidates from candidates in order (e.g. happy-eyeballs order from a
ConnectorTargetStream), keeps up to max_in_flight dials racing
concurrently via dial, and returns the first successful connection together
with the address it connected to. If every candidate fails (to resolve or to
connect), the last error is returned.