---
title: "CFMachPortGetContext(_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfmachportgetcontext(_:_:)"
---

# CFMachPortGetContext(_:_:)

Returns the context information for a CFMachPort object.

## Declaration

```swift
func CFMachPortGetContext(_ port: CFMachPort!, _ context: UnsafeMutablePointer<CFMachPortContext>!)
```

## Parameters

- `port`: The CFMachPort object to examine.
- `context`: A pointer to the structure into which the context information for port is to be copied. The information being returned is usually the same information you passed to doc://com.apple.corefoundation/documentation/CoreFoundation/CFMachPortCreate(_:_:_:_:) or doc://com.apple.corefoundation/documentation/CoreFoundation/CFMachPortCreateWithPort(_:_:_:_:_:) when creating port. However, if doc://com.apple.corefoundation/documentation/CoreFoundation/CFMachPortCreateWithPort(_:_:_:_:_:) returned a cached CFMachPort object instead of creating a new object, context is filled with information from the original CFMachPort object instead of the information you passed to the function.

## Discussion

Discussion The context version number for CFMachPort objects is currently 0. Before calling this function, you need to initialize the version member of context to 0.

## See Also

### Examining a CFMachPort Object

- [CFMachPortGetInvalidationCallBack(_:)](corefoundation/cfmachportgetinvalidationcallback(_:).md)
- [CFMachPortGetPort(_:)](corefoundation/cfmachportgetport(_:).md)
- [CFMachPortIsValid(_:)](corefoundation/cfmachportisvalid(_:).md)
