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

#984 in Network programming

Download history 218/week @ 2023-10-30 101/week @ 2023-11-06 59/week @ 2023-11-13 110/week @ 2023-11-20 129/week @ 2023-11-27 272/week @ 2023-12-04 831/week @ 2023-12-11 613/week @ 2023-12-18 147/week @ 2023-12-25 188/week @ 2024-01-01 257/week @ 2024-01-08 144/week @ 2024-01-15 128/week @ 2024-01-22 292/week @ 2024-01-29 168/week @ 2024-02-05 349/week @ 2024-02-12

941 downloads per month
Used in 2 crates

MIT license

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();

No runtime deps