Language : 🇺🇸 English | 🇨🇳 简体ä¸æ–‡
Overview
port-selector is a rust library that provides port availability checking, port filtering based on conditions and occupy specified ports.
Installation
-
Get the latest version -> https://crates.io/crates/port-selector
-
Add the dependent
[]
= "0.1.5"
- 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 · take_up_tcp_port · take_up_udp_port · take_up_port · random_take_up_tcp_port · random_take_up_udp_port · random_take_up_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 += 1
until the port is available
select_free_port
Gets a matching port based on the Selector
parameter constraint
take_up_tcp_port
Occupy port on tcp
take_up_udp_port
Occupy port on udp
take_up_port
Occupy port on tcp && udp
random_take_up_tcp_port
Randomly occupied port on tcp by the system
random_take_up_udp_port
Randomly occupied port on udp by the system
random_take_up_port
Randomly occupy tcp && udp ports by the system