pub fn find_available_port_in_range<R>(
    range: R,
    local_address_type: LocalAddressType
) -> Option<u16>where
    R: ExactSizeIterator<Item = u16>,
Expand description

finds an available port within a range

Examples found in repository?
src/utils.rs (line 8)
6
7
8
9
10
11
12
13
14
15
pub fn find_available_port(search: bool, start_port: u16, local_address_type: LocalAddressType) -> Option<u16> {
    if search {
        find_available_port_in_range(start_port..MAX_PORT, local_address_type)
    } else {
        let local_address = local_address_type.to_ip_v4();
        TcpListener::bind((local_address, start_port))
            .is_ok()
            .then_some(start_port)
    }
}