port_check

Crates.ioport_check
lib.rsport_check
version0.2.1
sourcesrc
created_at2019-03-21 15:22:02.223525
updated_at2024-04-01 15:28:42.376456
descriptionGet a free local port or check if a port somewhere is reachable.
homepagehttps://github.com/ufoscout/port-check-rs
repositoryhttps://github.com/ufoscout/port-check-rs
max_upload_size
id122918
size22,749
Francesco CinĂ  (ufoscout)

documentation

README

port_check

crates.io Build Status codecov

A simple rust library to get a free local port or to check if a port somewhere is reachable

Example:

use port_check::*;
use std::time::Duration;

// --------------------------------------------------------------------
// If not specified, all port checks are performed for IPv4 addresses.
// --------------------------------------------------------------------

// get a free local port
let free_port = free_local_port().unwrap();

// get a free local port between 10000 and 15000
let free_port_in_range = free_local_port_in_range(10000..=15000);

// check whether a remote port is reachable
let is_reachable = is_port_reachable("192.0.2.0:8080");
// or
let is_reachable = is_port_reachable_with_timeout("192.0.2.0:8080", Duration::from_millis(10_000));



// --------------------------------------------------------------------
// IPv6 checks are supported too
// --------------------------------------------------------------------

let free_ipv6_port = free_local_ipv6_port().unwrap();

let is_ipv6_port_free = is_local_port_free(Port::ipv6(free_ipv6_port));
// or
let is_ipv6_port_free = is_local_ipv6_port_free(free_ipv6_port);

Commit count: 27

cargo fmt