Class

NSXPCListener

A listener that waits for new incoming connections, configures them, and accepts or rejects them.

Overview

Each XPC service, launchd agent, or launchd daemon typically has at least one NSXPCListener object that listens for connections to a specified service name. Each listener must have a delegate that conforms to the NSXPCListenerDelegate protocol. When the listener receives a new connection request, it creates a new NSXPCConnection object, then asks the delegate to inspect, configure, and resume the connection object by calling the delegate's listener(_:shouldAcceptNewConnection:) method.

Topics

Initializers

init(machServiceName: String)

Initializes a listener in a LaunchAgent or LaunchDaemon which has a name advertised in a launchd.plist file.

Instance Properties

var delegate: NSXPCListenerDelegate?

The delegate for the listener.

var endpoint: NSXPCListenerEndpoint

Returns an endpoint object that may be sent over an existing connection.

Instance Methods

func invalidate()

Invalidates the listener.

func resume()

Starts processing of incoming requests.

func suspend()

Suspends the listener.

Type Methods

class func anonymous()

Returns a new anonymous listener connection.

class func service()

Returns the singleton listener used to listen for incoming connections in an XPC service.

Relationships

Inherits From

Conforms To

See Also

XPC Services

protocol NSXPCListenerDelegate

The protocol that delegates to the XPC listener use to accept or reject new connections.

class NSXPCListenerEndpoint

An object that names a specific XPC listener.