xpc_connection_create_mach_service(_:_:_:)
Creates a new connection object that represents a Mach service.
Declaration
func xpc_connection_create_mach_service(_ name: UnsafePointer<CChar>, _ targetq: dispatch_queue_t?, _ flags: UInt64) -> xpc_connection_tParameters
- 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 the default target queue oflibdispatch, defined asDISPATCH_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(_:).