#port #network

get-port

Get an available TCP/UDP port

10 stable releases (4 major)

new 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

#126 in Network programming

Download history 250/week @ 2021-04-02 466/week @ 2021-04-09 584/week @ 2021-04-16 472/week @ 2021-04-23 643/week @ 2021-04-30 589/week @ 2021-05-07 430/week @ 2021-05-14 619/week @ 2021-05-21 285/week @ 2021-05-28 333/week @ 2021-06-04 384/week @ 2021-06-11 596/week @ 2021-06-18 459/week @ 2021-06-25 754/week @ 2021-07-02 698/week @ 2021-07-09 487/week @ 2021-07-16

2,226 downloads per month
Used in oha

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