<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc_connection_send_message_with_reply_sync(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_connection_send_message_with_reply_sync"
  },
  "title" : "xpc_connection_send_message_with_reply_sync(_:_:)"
}
-->

# xpc_connection_send_message_with_reply_sync(_:_:)

Sends a message over the connection and blocks the caller until it receives a reply.

```
func xpc_connection_send_message_with_reply_sync(_ connection: xpc_connection_t, _ message: xpc_object_t) -> xpc_object_t
```

## Parameters

`connection`

The connection for sending the message.

`message`

The message to send. This must be a dictionary object.

## Return Value

The message that the remote service sends in reply to the original message. If the remote service exits prematurely before receiving the reply, the [`XPC_ERROR_CONNECTION_INTERRUPTED`](/documentation/XPC/XPC_ERROR_CONNECTION_INTERRUPTED-swift.var) error returns. If the connection becomes invalid before the remote service sends the message, the [`XPC_ERROR_CONNECTION_INVALID`](/documentation/XPC/XPC_ERROR_CONNECTION_INVALID-swift.var) error returns.

## Discussion

You are responsible for releasing the returned object.

## Discussion

This API supports priority inversion avoidance, so use it instead of combining [`xpc_connection_send_message_with_reply(_:_:_:_:)`](/documentation/XPC/xpc_connection_send_message_with_reply(_:_:_:_:)) with a semaphore.

Invoking this API from a queue that is a part of the target queue hierarchy results in deadlocks under certain conditions.

Be judicious about your use of this API. It can block indefinitely, so if you are using it to implement an API that you can call from the main thread, you might consider allowing the API to take a queue and callback block so that results arrive asynchronously, if possible.

---

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)