---
title: CFSocketCallBack
framework: corefoundation
role: symbol
role_heading: Type Alias
path: corefoundation/cfsocketcallback
---

# CFSocketCallBack

Callback invoked when certain types of activity takes place on a CFSocket object.

## Declaration

```swift
typealias CFSocketCallBack = (CFSocket?, CFSocketCallBackType, CFData?, UnsafeRawPointer?, UnsafeMutableRawPointer?) -> Void
```

## Parameters

- `s`: The CFSocket object that experienced some activity.
- `callbackType`: The type of activity detected.
- `address`: A CFData object holding the contents of a struct sockaddr appropriate for the protocol family of s (struct sockaddr_in or struct sockaddr_in6, for example), identifying the remote address to which s is connected. This value is NULL except for kCFSocketAcceptCallBack and kCFSocketDataCallBack callbacks.
- `data`: Data appropriate for the callback type. For a kCFSocketConnectCallBack that failed in the background, it is a pointer to an SInt32 error code; for a kCFSocketAcceptCallBack, it is a pointer to a doc://com.apple.corefoundation/documentation/CoreFoundation/CFSocketNativeHandle; or for a kCFSocketDataCallBack, it is a CFData object containing the incoming data. In all other cases, it is NULL.
- `info`: The info member of the doc://com.apple.corefoundation/documentation/CoreFoundation/CFSocketContext structure that was used when creating the CFSocket object.

## Discussion

Discussion You specify this callback when you create the CFSocket object with CFSocketCreate(_:_:_:_:_:_:_:), CFSocketCreateConnectedToSocketSignature(_:_:_:_:_:_:), CFSocketCreateWithNative(_:_:_:_:_:), or CFSocketCreateWithSocketSignature(_:_:_:_:_:).
