---
title: SocketPort
framework: foundation
role: symbol
role_heading: Class
path: foundation/socketport
---

# SocketPort

A port that represents a BSD socket.

## Declaration

```swift
class SocketPort
```

## Overview

Overview A SocketPort object can be used as an endpoint for distributed object connections. Companion classes, NSMachPort and MessagePort, allow for local (on the same machine) communication only. The SocketPort class allows for both local and remote communication, but may be more expensive than the others for the local case. note: The SocketPort class conforms to the NSCoding protocol, but only supports coding by an NSPortCoder. Port and its other subclasses do not support archiving.

## Topics

### Creating Instances

- [init()](foundation/socketport/init().md)
- [init(tcpPort:)](foundation/socketport/init(tcpport:)-6hgbo.md)
- [init(protocolFamily:socketType:protocol:address:)](foundation/socketport/init(protocolfamily:sockettype:protocol:address:).md)
- [init(protocolFamily:socketType:protocol:socket:)](foundation/socketport/init(protocolfamily:sockettype:protocol:socket:).md)
- [init(remoteWithTCPPort:host:)](foundation/socketport/init(remotewithtcpport:host:).md)
- [init(remoteWithProtocolFamily:socketType:protocol:address:)](foundation/socketport/init(remotewithprotocolfamily:sockettype:protocol:address:).md)

### Getting Information

- [address](foundation/socketport/address.md)
- [protocol](foundation/socketport/protocol.md)
- [protocolFamily](foundation/socketport/protocolfamily.md)
- [socket](foundation/socketport/socket.md)
- [socketType](foundation/socketport/sockettype.md)

### Initializers

- [init(TCPPort:)](foundation/socketport/init(tcpport:)-17uiq.md)

## Relationships

### Inherits From

- [Port](foundation/port.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Sockets

- [Host](foundation/host.md)
- [Port](foundation/port.md)
