get-port

Crates.ioget-port
lib.rsget-port
version4.0.0
sourcesrc
created_at2020-01-25 23:20:22.177603
updated_at2021-07-21 09:23:08.035607
descriptionGet an available TCP/UDP port
homepage
repositoryhttps://github.com/carlos-menezes/get-port
max_upload_size
id201984
size11,993
Carlos Menezes (carlos-menezes)

documentation

README

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();
Commit count: 32

cargo fmt