<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFSocketCallBackType",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@E@CFSocketCallBackType"
  },
  "title" : "CFSocketCallBackType"
}
-->

# CFSocketCallBackType

Types of socket activity that can cause the callback function of a CFSocket object to be called.

```
struct CFSocketCallBackType
```

## Overview

The callback types for which a callback is made is determined when the CFSocket object is created, such as with [`CFSocketCreate(_:_:_:_:_:_:_:)`](/documentation/CoreFoundation/CFSocketCreate(_:_:_:_:_:_:_:)), or later with [`CFSocketEnableCallBacks(_:_:)`](/documentation/CoreFoundation/CFSocketEnableCallBacks(_:_:)) and [`CFSocketDisableCallBacks(_:_:)`](/documentation/CoreFoundation/CFSocketDisableCallBacks(_:_:)).

The `kCFSocketReadCallBack`, `kCFSocketAcceptCallBack`, and `kCFSocketDataCallBack` callbacks are mutually exclusive.

### Version-Notes

`kCFSocketWriteCallBack` is available in macOS 10.2 and later.

## Topics

### Constants

[`kCFSocketNoCallBack`](/documentation/CoreFoundation/CFSocketCallBackType/kCFSocketNoCallBack)

No callback should be made for any activity.

[`kCFSocketReadCallBack`](/documentation/CoreFoundation/CFSocketCallBackType/readCallBack)

The callback is called when data is available to be read or a new connection is waiting to be accepted. The data is not automatically read; the callback must read the data itself.

[`kCFSocketAcceptCallBack`](/documentation/CoreFoundation/CFSocketCallBackType/acceptCallBack)

New connections will be automatically accepted and the callback is called with the data argument being a pointer to a [`CFSocketNativeHandle`](/documentation/CoreFoundation/CFSocketNativeHandle) of the child socket. This callback is usable only with listening sockets.

[`kCFSocketDataCallBack`](/documentation/CoreFoundation/CFSocketCallBackType/dataCallBack)

Incoming data will be read in chunks in the background and the callback is called with the data argument being a CFData object containing the read data.

[`kCFSocketConnectCallBack`](/documentation/CoreFoundation/CFSocketCallBackType/connectCallBack)

[`kCFSocketWriteCallBack`](/documentation/CoreFoundation/CFSocketCallBackType/writeCallBack)

The callback is called when the socket is writable. This callback type may be useful when large amounts of data are being sent rapidly over the socket and you want a notification when there is space in the kernel buffers for more data.

## Relationships

### Conforms To

[`SetAlgebra`](/documentation/Swift/SetAlgebra)

[`Equatable`](/documentation/Swift/Equatable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`OptionSet`](/documentation/Swift/OptionSet)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`ExpressibleByArrayLiteral`](/documentation/Swift/ExpressibleByArrayLiteral)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)