<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCPeerHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC14XPCPeerHandlerP"
  },
  "title" : "XPCPeerHandler"
}
-->

# XPCPeerHandler

A type that handles incoming messages from a client and session cancellation.

```
@preconcurrency protocol XPCPeerHandler : Sendable
```

## Topics

### Receiving client messages

[`func handleIncomingRequest(Self.Input) -> Self.Output?`](/documentation/XPC/XPCPeerHandler/handleIncomingRequest(_:))

A closure that receives a message from a client and optionally provides a reply.

[`associatedtype Input`](/documentation/XPC/XPCPeerHandler/Input)

A type that represents a message from a client.

[`associatedtype Output`](/documentation/XPC/XPCPeerHandler/Output)

A type that represents a response to an incoming request.

### Responding to session cancellation

[`func handleCancellation(error: XPCRichError)`](/documentation/XPC/XPCPeerHandler/handleCancellation(error:))

A closure the system invokes when it cancels a session with a client.

## Relationships

### Inherits From

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)