Skip to main content

spawn

Function spawn 

Source
pub async fn spawn(
    cfg: &StreamListenerConfig,
    router: Arc<SniRouter>,
    connect_timeout: Duration,
    shutdown_rx: Receiver<bool>,
) -> Result<SocketAddr>
Expand description

Binds the TCP listener (fail-fast) and spawns its accept loop, returning the bound address (the OS-assigned port when cfg.port == 0). The loop stops accepting when shutdown_rx flips to true. When router has SNI routes, each connection’s TLS ClientHello is peeked to pick a backend by hostname.