Crates.io | get-port |
lib.rs | get-port |
version | 4.0.0 |
source | src |
created_at | 2020-01-25 23:20:22.177603 |
updated_at | 2021-07-21 09:23:08.035607 |
description | Get an available TCP/UDP port |
homepage | |
repository | https://github.com/carlos-menezes/get-port |
max_upload_size | |
id | 201984 |
size | 11,993 |
Get an available TCP/UDP port
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();