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

# CFMessagePortCallBack

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

```
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 [`CFMessagePortContext`](/documentation/CoreFoundation/CFMessagePortContext) structure that was used when creating `local`.

## 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

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.

---

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)