> For the complete documentation index, see [llms.txt](https://docs.9proxy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.9proxy.com/developers/sdk/sdk-native-c/functions/getportsavailable.md).

# GetPortsAvailable

Filter the input array and return only ports that are currently available.

{% code overflow="wrap" %}

```c
int GetPortsAvailable(unsigned int* ports, int portsLen, unsigned int** outArr, int* outLen)
```

{% endcode %}

***

## Parameters

* **ports**: Input array of ports.
* **portsLen**: Number of elements in ports.

## Return Value

* int: 0 on success.
* outArr: Output pointer; receives an allocated array of available ports (free with FreeBuf).
* outLen: Output count; number of elements in outArr.

## Example

```c
// example

unsigned inPorts[]={60000,60001,60002};
unsigned* out=NULL; int n=0;
GetPortsAvailable(inPorts,3,&out,&n);
if (out){ FreeBuf(out);}

```
