<!--
{
  "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/handleIncomingRequest(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC14XPCPeerHandlerP21handleIncomingRequesty6OutputQzSg5InputQzF"
  },
  "title" : "handleIncomingRequest(_:)"
}
-->

# handleIncomingRequest(_:)

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

```
func handleIncomingRequest(_: Self.Input) -> Self.Output?
```

## Return Value

A response message, if any, to send back to the client; otherwise <doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0>.

## Discussion

If the closure returns <doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0>, you can still send use [`send(message:)`](/documentation/XPC/XPCSession/send(message:)) to send an asynchronous reply after handling the message.

---

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)