> 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/getportsfreewithlimit.md).

# GetPortsFreeWithLimit

Retrieve up to limit free (unused) ports according to the current SDK settings.

{% code overflow="wrap" %}

```c
int GetPortsFreeWithLimit(unsigned int limit, uint32_t** outPtr, int* outLen)
```

{% endcode %}

***

## Parameters

* **limit**: Maximum number of free ports to return.

## Return Value

* int: 0 if success.
* outPtr: Pointer to an array of free ports (must be freed with FreeBuf).
* outLen: Number of ports in outPtr.

## Example

```c
// example

uint32_t* out = NULL; 
int n = 0;
GetPortsFreeWithLimit(5, &out, &n);
if (out) { 
    for (int i = 0; i < n; i++) {
        printf("Free port: %u\n", out[i]);
    }
    FreeBuf(out);
}

```
