get_random_available_port

Function get_random_available_port 

Source
pub fn get_random_available_port() -> u16
Expand description

Finds a random open port available for listening at, by spawning a TCP server with port “zero” (which prompts the OS to just use any available port). Between calling this function and trying to bind to this port, the port may be given to another process, so this must be used with care (since here we only use it for tests, it’s mostly okay).