<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Event",
  "identifier" : "/documentation/Event/SocketAddress/port",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Event"
    ],
    "preciseIdentifier" : "s:5Event13SocketAddressV4ports6UInt16Vvp"
  },
  "title" : "port"
}
-->

# port

The port number in host byte order.

```
var port: UInt16 { get }
```

## Discussion

Inspects the underlying storage’s `ss_family` and reads `sin_port` or `sin6_port`
accordingly, converting from network byte order (big-endian) back to host byte
order. Returns `0` if the address family is neither `AF_INET` nor `AF_INET6` —
a defensive fallback that should not occur for addresses produced by this API.