Skip to main content

port_taken

Function port_taken 

Source
pub fn port_taken(port: u16) -> bool
Expand description

Whether something is already listening on this port.

Asked before the daemon is launched only to make the refusal legible: a bind that fails inside the daemon reports an errno against an address, and the useful sentence — that this is probably the node you already started — is one this side can write and that side cannot. It is a race in principle, and harmless in practice: losing the race produces exactly the message not checking would have.