---
title: port
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/netservice/port
---

# port

The port on which the service is listening for connections.

## Declaration

```swift
var port: Int { get }
```

## Discussion

Discussion If the object was initialized by calling init(domain:type:name:port:) (whether by your code or by a browser object), then the value was set when the object was first initialized. If the object was initialized by calling init(domain:type:name:), the value of this property is not valid (-1) until after the service has successfully been resolved (when addresses is non-nil). note: This became a property in OS X v10.9 and iOS 7, but the underlying getter method (port) has been available since this class was first introduced.

## See Also

### Using Network Services

- [publish()](foundation/netservice/publish().md)
- [publish(options:)](foundation/netservice/publish(options:).md)
- [resolve()](foundation/netservice/resolve().md)
- [resolve(withTimeout:)](foundation/netservice/resolve(withtimeout:).md)
- [startMonitoring()](foundation/netservice/startmonitoring().md)
- [stop()](foundation/netservice/stop().md)
- [stopMonitoring()](foundation/netservice/stopmonitoring().md)
