> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::get_preferred_network_ports

> Get the preferred network ports from the specified environment variable.

```cpp showLineNumbers={false}
std::vector<int> holoscan::get_preferred_network_ports(
    const char *env_var_name
)
```

Get the preferred network ports from the specified environment variable.

This method reads the specified environment variable and returns a vector of preferred network ports. The environment variable is expected to be a comma-separated list of integers. If the environment variable is not set, is empty, or contains invalid or non-integer values, an empty vector is returned.

**Returns:** The vector containing the preferred network ports. If the environment variable is not set, is empty, or no valid port numbers are found, an empty vector is returned.

**Parameters**

The name of the environment variable to read.