2 releases
| 0.1.1 | Sep 24, 2024 |
|---|---|
| 0.1.0 | Sep 24, 2024 |
#10 in #udp-port
1,269 downloads per month
Used in 5 crates
8KB
80 lines
openport
Find a free unused port
Features
rand: Addpick_random_unused_portpub fn that allows finding a random port within the range15000..25000
Usage
The following steps describe a basic usage of openport:
- Call
openport::pick_unused_portand pass a range of ports you want to find a free port in - Enable the
randfeature and callopenport::pick_random_unused_portto find a random open port within the range15000..16000 - Call
openport::is_freeto check if a specific port is open on both TCP and UDP - Call
openport::is_free_tcpto check if a specific port is open on TCP - Call
openport::is_free_udpto check if a specific port is open on UDP
openport - find a free unused port
Finds a free port, that is unused on both TCP and UDP.
Usage:
use openport::pick_unused_port;
let port: u16 = pick_unused_port(15000..16000).expect("No ports free");
License
openport is provided under the MPL v2.0 license. Please refer to the LICENSE file for more details.
Dependencies
~82KB