Language : 🇺🇸 English | 🇨🇳 简体ä¸æ–‡
Overview
port-selector is a rust library that mainly provides port availability checking and port filtering based on conditions.
Install
-
Get the latest version -> https://crates.io/crates/port-selector
-
Add the dependent
[]
= "x.x.x"
- use
use ;
Goods
fn -> is_free_tcp · is_free_udp · is_free · random_free_tcp_port · random_free_udp_port · random_free_port · select_from_given_port · select_free_port
Documentation
Port
u16
type alias
pub type Port = u16;
Selector
The select_free_port
requires a structure passed in
is_free_tcp
Check whether the port is not used on TCP
is_free_udp
Check whether the port is not used on UDP
is_free
Check whether the port is not used on TCP and UDP
random_free_tcp_port
The system randomly assigns available TCP ports
random_free_udp_port
The system randomly assigns available UDP ports
random_free_port
The system randomly assigns available TCP and UDP ports
select_from_given_port
Check from given_port
and return the first available port
Return if given_port
is available; Otherwise given_port += given_port
until the port is available
select_free_port
Gets a matching port based on the Selector
parameter constraint