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

# CFMachPortCallBack

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

```
typealias CFMachPortCallBack = (CFMachPort?, UnsafeMutableRawPointer?, CFIndex, UnsafeMutableRawPointer?) -> Void
```

## Parameters

`port`

The CFMachPort object on which the message `msg` was received.

`msg`

The Mach message received on `port`. The pointer is to a `mach_msg_header_t` structure.

`size`

Size of the Mach message `msg`, excluding the message trailer.

`info`

The `info` member of the [`CFMachPortContext`](/documentation/CoreFoundation/CFMachPortContext) structure used when creating `port`.

## Discussion

You specify this callback when creating a CFMachPort object with either [`CFMachPortCreate(_:_:_:_:)`](/documentation/CoreFoundation/CFMachPortCreate(_:_:_:_:)) or [`CFMachPortCreateWithPort(_:_:_:_:_:)`](/documentation/CoreFoundation/CFMachPortCreateWithPort(_:_:_:_:_:)). To receive messages on a CFMachPort object (and have this callback invoked), you must create a run loop source for the port and add it to a run loop.

---

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)