---
title: CFMessagePortCallBack
framework: corefoundation
role: symbol
role_heading: Type Alias
path: corefoundation/cfmessageportcallback
---

# CFMessagePortCallBack

Callback invoked to process a message received on a CFMessagePort object.

## Declaration

```swift
typealias CFMessagePortCallBack = (CFMessagePort?, Int32, CFData?, UnsafeMutableRawPointer?) -> Unmanaged<CFData>?
```

## Parameters

- `local`: The local message port that received the message.
- `msgid`: An arbitrary integer value assigned to the message by the sender.
- `data`: The message data.
- `info`: The info member of the doc://com.apple.corefoundation/documentation/CoreFoundation/CFMessagePortContext structure that was used when creating local.

## Return Value

Return Value Data to send back to the sender of the message. The system releases the returned CFData object. Return NULL if you want an empty reply returned to the sender.

## Discussion

Discussion If you want the message data to persist beyond this callback, you must explicitly create a copy of data rather than merely retain it; the contents of data will be deallocated after the callback exits.

## See Also

### Callbacks

- [CFMessagePortInvalidationCallBack](corefoundation/cfmessageportinvalidationcallback.md)
