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

Download history 286/week @ 2024-07-21 214/week @ 2024-07-28 314/week @ 2024-08-04 378/week @ 2024-08-11 273/week @ 2024-08-18 680/week @ 2024-08-25 230/week @ 2024-09-01 243/week @ 2024-09-08 554/week @ 2024-09-15 307/week @ 2024-09-22 172/week @ 2024-09-29 318/week @ 2024-10-06 330/week @ 2024-10-13 289/week @ 2024-10-20 192/week @ 2024-10-27 161/week @ 2024-11-03

988 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