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

# GetPortsWithLimit

Retrieve up to limit ports according to the current SDK settings.

{% code overflow="wrap" %}

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

{% endcode %}

***

## Parameters

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

## Return Value

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

## Example

```c
// example

uint32_t* out=NULL; int n=0;
GetPortsWithLimit(10,&out,&n);
if (out){ FreeBuf(out);}

```
