Skip to main content

bind

Function bind 

Source
pub async fn bind(config: &ServerConfig) -> Result<TcpListener>
Expand description

Bind the API server’s port without starting to serve.

Callers that need to know the port before traffic flows — anything binding port 0, where the OS chooses — take the listener from here and hand it to serve_on. Splitting bind from serve is what makes an ephemeral port usable: the alternative is binding twice and racing whoever grabs it in between.