Function random_port::is_free

source ·
pub fn is_free(port: u16, host: Option<String>, protocol: Protocol) -> bool
Expand description

Check if a port is free in the local machine. If the host is not specified, it will check on all local addresses defined in the system.

  • port: The port to check.
  • host: The host to check. Can be either an Ipv4 or Ipv6 address.
  • protocol: The protocol to check. Can be either Protocol::Tcp, Protocol::Udp or Protocol::All.