- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
A CFSocket is a communications channel implemented with a BSD socket.
For most uses of this API, you will need to include three headers:
CFSocket can be created from scratch with
CFSocket. CFSocket objects can also be created to wrap an existing BSD socket by calling
CFSocket. Finally, you can create a CFSocket and connect simultaneously to a remote host by calling
To listen for messages, you need to create a run loop source with
CFSocket and add it to a run loop with
CFRun. You can select the types of socket activities, such as connection attempts or data arrivals, that cause the source to fire and invoke your CFSocket’s callback function. To send data, you store the data in a CFData and call
Unlike Mach and message ports, sockets support communication over a network.