---
title: MessagePort
framework: foundation
role: symbol
role_heading: Class
path: foundation/messageport
---

# MessagePort

A port that can be used as an endpoint for distributed object connections (or raw messaging).

## Declaration

```swift
class MessagePort
```

## Overview

Overview MessagePort is a subclass of Port that allows for local (on the same machine) communication only. A companion class, SocketPort, allows for both local and remote communication, but may be more expensive than MessagePort for the local case. MessagePort defines no additional methods over those already defined by Port. note: MessagePort conforms to the NSCoding protocol, but only supports coding by an NSPortCoder object. Port and its subclasses do not support archiving. important: Avoid MessagePort. There’s little reason to use MessagePort rather than NSMachPort or SocketPort. There’s no particular performance or functionality advantage. It is recommended avoiding its use. MessagePort may be deprecated in the macOS 10.6 or later.

## 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

### Related Documentation

- [Distributed Objects Programming Topics](apple-archive/documentation/Cocoa/Conceptual/DistrObjects.md)

### Legacy

- [NSMachPortDelegate](foundation/nsmachportdelegate.md)
- [NSMachPort](foundation/nsmachport.md)
- [PortDelegate](foundation/portdelegate.md)
- [PortMessage](foundation/portmessage.md)
- [NSProtocolChecker](foundation/nsprotocolchecker.md)
