---
title: "localPort(_:)"
framework: network
role: symbol
role_heading: Instance Method
path: "network/nwparametersprovider/localport(_:)"
---

# localPort(_:)

Specify a specific port to use as the local endpoint, letting the system select the address.

## Declaration

```swift
func localPort(_ port: NWEndpoint.Port) -> Self
```

## Parameters

- `port`: The local port to require. Force a specific local port to be used.

## Discussion

Discussion For connections, this will be used to initiate traffic; for listeners, this will be used for receiving incoming connections.
