---
title: XPC connections
framework: xpc
role: collectionGroup
role_heading: API Collection
path: xpc/xpc-connections
---

# XPC connections

Create and manage connections to services using connection-based APIs.

## Overview

Overview Use these APIs to work with XPC connections and related types — for example, when a framework function that you call returns an xpc_connection_t. But, in most situations, the listener- and session-based APIs are a better choice for designing XPC communication protocols. For more information, see Creating XPC services.

## Topics

### Creation

- [xpc_connection_t](xpc/xpc_connection_t.md)
- [xpc_connection_create(_:_:)](xpc/xpc_connection_create(_:_:).md)
- [xpc_connection_create_from_endpoint(_:)](xpc/xpc_connection_create_from_endpoint(_:).md)
- [xpc_connection_create_mach_service(_:_:_:)](xpc/xpc_connection_create_mach_service(_:_:_:).md)
- [xpc_connection_set_target_queue(_:_:)](xpc/xpc_connection_set_target_queue(_:_:).md)
- [XPC_CONNECTION_MACH_SERVICE_LISTENER](xpc/xpc_connection_mach_service_listener.md)
- [XPC_CONNECTION_MACH_SERVICE_PRIVILEGED](xpc/xpc_connection_mach_service_privileged.md)

### Event handling

- [xpc_connection_set_event_handler(_:_:)](xpc/xpc_connection_set_event_handler(_:_:).md)
- [xpc_handler_t](xpc/xpc_handler_t.md)
- [xpc_connection_handler_t](xpc/xpc_connection_handler_t.md)

### Life cycle

- [xpc_main(_:)](xpc/xpc_main(_:).md)
- [xpc_connection_activate(_:)](xpc/xpc_connection_activate(_:).md)
- [xpc_connection_suspend(_:)](xpc/xpc_connection_suspend(_:).md)
- [xpc_connection_resume(_:)](xpc/xpc_connection_resume(_:).md)
- [xpc_connection_cancel(_:)](xpc/xpc_connection_cancel(_:).md)
- [xpc_transaction_begin()](xpc/xpc_transaction_begin().md)
- [xpc_transaction_end()](xpc/xpc_transaction_end().md)
- [xpc_connection_copy_invalidation_reason(_:)](xpc/xpc_connection_copy_invalidation_reason(_:).md)

### Messages

- [xpc_connection_send_message(_:_:)](xpc/xpc_connection_send_message(_:_:).md)
- [xpc_connection_send_barrier(_:_:)](xpc/xpc_connection_send_barrier(_:_:).md)
- [xpc_connection_send_message_with_reply(_:_:_:_:)](xpc/xpc_connection_send_message_with_reply(_:_:_:_:).md)
- [xpc_connection_send_message_with_reply_sync(_:_:)](xpc/xpc_connection_send_message_with_reply_sync(_:_:).md)
- [xpc_main(_:)](xpc/xpc_main(_:).md)

### Remote peer information

- [xpc_connection_get_name(_:)](xpc/xpc_connection_get_name(_:).md)
- [xpc_connection_get_euid(_:)](xpc/xpc_connection_get_euid(_:).md)
- [xpc_connection_get_egid(_:)](xpc/xpc_connection_get_egid(_:).md)
- [xpc_connection_get_pid(_:)](xpc/xpc_connection_get_pid(_:).md)
- [xpc_connection_get_asid(_:)](xpc/xpc_connection_get_asid(_:).md)
- [xpc_connection_set_peer_entitlement_exists_requirement(_:_:)](xpc/xpc_connection_set_peer_entitlement_exists_requirement(_:_:).md)
- [xpc_connection_set_peer_entitlement_matches_value_requirement(_:_:_:)](xpc/xpc_connection_set_peer_entitlement_matches_value_requirement(_:_:_:).md)
- [xpc_connection_set_peer_lightweight_code_requirement(_:_:)](xpc/xpc_connection_set_peer_lightweight_code_requirement(_:_:).md)
- [xpc_connection_set_peer_platform_identity_requirement(_:_:)](xpc/xpc_connection_set_peer_platform_identity_requirement(_:_:).md)
- [xpc_connection_set_peer_team_identity_requirement(_:_:)](xpc/xpc_connection_set_peer_team_identity_requirement(_:_:).md)
- [xpc_connection_set_peer_code_signing_requirement(_:_:)](xpc/xpc_connection_set_peer_code_signing_requirement(_:_:).md)

### Context

- [xpc_connection_set_context(_:_:)](xpc/xpc_connection_set_context(_:_:).md)
- [xpc_connection_get_context(_:)](xpc/xpc_connection_get_context(_:).md)
- [xpc_connection_set_finalizer_f(_:_:)](xpc/xpc_connection_set_finalizer_f(_:_:).md)
- [xpc_finalizer_t](xpc/xpc_finalizer_t.md)

### Endpoints

- [xpc_endpoint_create(_:)](xpc/xpc_endpoint_create(_:).md)
- [xpc_endpoint_t](xpc/xpc_endpoint_t.md)

### Errors

- [XPC_ERROR_CONNECTION_INVALID](xpc/xpc_error_connection_invalid-swift.var.md)
- [XPC_ERROR_CONNECTION_INTERRUPTED](xpc/xpc_error_connection_interrupted-swift.var.md)
- [XPC_ERROR_TERMINATION_IMMINENT](xpc/xpc_error_termination_imminent-swift.var.md)

## See Also

### Additional Types

- [XPC objects](xpc/xpc-objects.md)
- [Utilities](xpc/utilities.md)
