---
title: CFMachPortCallBack
framework: corefoundation
role: symbol
role_heading: Type Alias
path: corefoundation/cfmachportcallback
---

# CFMachPortCallBack

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

## Declaration

```swift
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 doc://com.apple.corefoundation/documentation/CoreFoundation/CFMachPortContext structure used when creating port.

## Discussion

Discussion You specify this callback when creating a CFMachPort object with either CFMachPortCreate(_:_:_:_:) or 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.

## See Also

### Callbacks

- [CFMachPortInvalidationCallBack](corefoundation/cfmachportinvalidationcallback.md)
