Contents

CFMessagePort

Declaration

class CFMessagePort

Overview

CFMessagePort objects provide a communications channel that can transmit arbitrary data between multiple threads or processes on the local machine.

You create a local message port with CFMessagePortCreateLocal(_:_:_:_:_:) and make it available to other processes by giving it a name, either when you create it or later with CFMessagePortSetName(_:_:). Other processes then connect to it using CFMessagePortCreateRemote(_:_:), specifying the name of the port.

To listen for messages, you need to create a run loop source with CFMessagePortCreateRunLoopSource(_:_:_:) and add it to a run loop with CFRunLoopAddSource(_:_:_:).

Your message port’s callback function will be called when a message arrives. To send data, you store the data in a CFData object and call CFMessagePortSendRequest(_:_:_:_:_:_:_:). You can optionally have the function wait for a reply and return the reply in another CFData object.

Message ports only support communication on the local machine. For network communication, you have to use a CFSocket object.

Topics

Creating a CFMessagePort Object

Configuring a CFMessagePort Object

Using a Message Port

Examining a Message Port

Getting the CFMessagePort Type ID

Callbacks

Data Types

Constants

See Also

Opaque Types