Skip to main content

port_is_free

Function port_is_free 

Source
fn port_is_free(listen: &str) -> Result<(), Error>
Expand description

Probe a host:port. Returns Ok(()) when nothing is listening (we can safely bind), Err describing the live owner otherwise. This is a race-prone pre-check (someone else can grab the port between probe and spawn) but in practice the failure mode it catches — a stale previous-boot daemon — has been alive for minutes, not seconds, so a single connect attempt is enough.