10 stable releases (4 major)
4.0.0 | Jul 21, 2021 |
---|---|
3.0.0 | Aug 25, 2020 |
2.0.0 | Aug 25, 2020 |
1.3.1 | Jan 27, 2020 |
0.1.0 | Jan 25, 2020 |
#1719 in Network programming
988 downloads per month
Used in 6 crates
(4 directly)
12KB
222 lines
get-port | crate
Get an available TCP/UDP port
Information
Example
For more examples, check src/tests.rs
.
// Return an available port, from the supplied range, available on localhost.
use get_port::tcp::TcpPort;
use get_port::{Ops, Range};
use get_port::udp::UdpPort;
let tcp_port = TcpPort::in_range("127.0.0.1", Range {min: 6000, max: 7000 }).unwrap();
let udp_port = UdpPort::in_range("127.0.0.1", Range {min: 8000, max: 9000 }).unwrap();