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

#1497 in Network programming

Download history 339/week @ 2024-06-13 149/week @ 2024-06-20 96/week @ 2024-06-27 177/week @ 2024-07-04 269/week @ 2024-07-11 190/week @ 2024-07-18 274/week @ 2024-07-25 245/week @ 2024-08-01 380/week @ 2024-08-08 338/week @ 2024-08-15 625/week @ 2024-08-22 255/week @ 2024-08-29 261/week @ 2024-09-05 583/week @ 2024-09-12 255/week @ 2024-09-19 169/week @ 2024-09-26

1,292 downloads per month
Used in 6 crates (4 directly)

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