Skip to main content

spawn

Function spawn 

Source
pub fn spawn(
    role: &'static str,
    initial: Option<TcpListener>,
    tls: Option<TlsSettings>,
) -> (RoleSocket, ListenerHandle)
Expand description

Starts a role’s accept loop.

initial is the socket to serve at once, or None for a role that is switched off — which parks until a reload hands it one. tls is the mode every connection is accepted under, read fresh each time so a renewed certificate, a changed handshake_timeout_ms and a tls.enabled flip all land on the next client without disturbing anyone already connected.

The address reported by local_addr before anything is bound is 0.0.0.0:0; nothing consults it until a connection arrives, and by then the accept task has published the real one.