Function

xpc_connection_create_mach_service(_:_:_:)

Declaration

func xpc_connection_create_mach_service(_ name: UnsafePointer<Int8>, _ targetq: DispatchQueue?, _ flags: UInt64) -> xpc_connection_t

Parameters

name

The name of the remote service with which to connect. The service name must exist in a Mach bootstrap that is accessible to the process and be advertised in a launchd.plist.

targetq

The GCD queue to which the event handler block will be submitted. This parameter may be NULL, in which case the connection's target queue will be libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. The target queue may be changed later with a call to xpc_connection_set_target_queue().

flags

Additional attributes with which to create the connection.

Return Value

A new connection object.

Discussion

If the XPC_CONNECTION_MACH_SERVICE_LISTENER flag is given to this method, then the connection returned will be a listener connection. Otherwise, a peer connection will be returned. See the documentation for xpc_connection_set_event_handler(_:_:) for the semantics of listener connections versus peer connections.

This method will succeed even if the named service does not exist. This is because the Mach namespace is not queried for the service name until the first call to xpc_connection_resume(_:).