2 releases

0.1.1 Sep 24, 2024
0.1.0 Sep 24, 2024

#10 in #udp-port

Download history 195/week @ 2025-09-18 173/week @ 2025-09-25 261/week @ 2025-10-02 277/week @ 2025-10-09 253/week @ 2025-10-16 226/week @ 2025-10-23 392/week @ 2025-10-30 727/week @ 2025-11-06 537/week @ 2025-11-13 448/week @ 2025-11-20 286/week @ 2025-11-27 471/week @ 2025-12-04 445/week @ 2025-12-11 332/week @ 2025-12-18 140/week @ 2025-12-25 282/week @ 2026-01-01

1,269 downloads per month
Used in 5 crates

MPL-2.0 license

8KB
80 lines

openport

Find a free unused port

Features

  • rand: Add pick_random_unused_port pub fn that allows finding a random port within the range 15000..25000

Usage

The following steps describe a basic usage of openport:

  1. Call openport::pick_unused_port and pass a range of ports you want to find a free port in
  2. Enable the rand feature and call openport::pick_random_unused_port to find a random open port within the range 15000..16000
  3. Call openport::is_free to check if a specific port is open on both TCP and UDP
  4. Call openport::is_free_tcp to check if a specific port is open on TCP
  5. Call openport::is_free_udp to check if a specific port is open on UDP

openport - find a free unused port

Crates.io Documentation

Finds a free port, that is unused on both TCP and UDP.

Usage:

use openport::pick_unused_port;
let port: u16 = pick_unused_port(15000..16000).expect("No ports free");

License

openport is provided under the MPL v2.0 license. Please refer to the LICENSE file for more details.

Dependencies

~82KB