Skip to main content

discover_reachable_endpoint

Function discover_reachable_endpoint 

Source
pub async fn discover_reachable_endpoint(
    discovery: &dyn Discovery,
) -> Result<String>
Expand description

Returns the first endpoint discovery reports that accepts a TCP connection.

A browse can report one service with several addresses, and a dual-stack host commonly does. Trying only the first means an IPv6 address the server does not listen on hides an IPv4 address it does, and the client retries the same unreachable one forever. This walks the candidates in the order DiscoveredServer::endpoints gives - IPv4 first - and stops at the first address that accepts. A failure moves to the next address immediately instead of waiting for a retry tick.

The probe is a TCP connection only: it decides reachability, and the session dials the returned endpoint itself. A host therefore sees one closed probe connection before the real one.

§Errors

Returns the backend’s error, an error when nothing advertises a dialable endpoint, and an error naming every attempt once all addresses refused or timed out. A backend error is not retried here; the caller decides whether to browse again.