holoscan::get_unused_network_ports

Beta
View as Markdown
std::vector<int> holoscan::get_unused_network_ports(
uint32_t num_ports = 1,
uint32_t min_port = 10000,
uint32_t max_port = 32767,
const std::vector<int> &used_ports = {},
const std::vector<int> &prefer_ports = {}
)

Generate a list of unused network ports within a specified range.

This method generates a vector of unused network ports based on the specified parameters. The generated ports are guaranteed to be unused at the time of generation. The generated ports can be used to bind to a network socket. The generated ports are not guaranteed to remain unused after generation.

Returns: The vector containing the generated unused network ports.

Parameters

num_ports
uint32_tDefaults to 1

The number of unused ports to generate (default: 1).

min_port
uint32_tDefaults to 10000

The minimum value of the port range (default: 10000).

max_port
uint32_tDefaults to 32767

The maximum value of the port range (default: 32767).

used_ports
const std::vector<int> &Defaults to {}

The vector of ports to exclude from the generated list (default: empty).

prefer_ports
const std::vector<int> &Defaults to {}

The vector of ports to prefer in the generated list (default: empty).