<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.0.0",
    "iPadOS: 2.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.3.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CFNetwork",
  "identifier" : "/documentation/CFNetwork/CFHostSetClient(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFHostSetClient"
  },
  "title" : "CFHostSetClient(_:_:_:)"
}
-->

# CFHostSetClient(_:_:_:)

Associates a client context and a callback function with a CFHost object or disassociates a client context and callback function that were previously set.

```
func CFHostSetClient(_ theHost: CFHost, _ clientCB: CFHostClientCallBack?, _ clientContext: UnsafeMutablePointer<CFHostClientContext>?) -> Bool
```

## Parameters

`theHost`

The host to modify. The value must not be `NULL`.

`clientCB`

The callback function to associate with `theHost`. The callback function will be called when a resolution completes or is cancelled. If you are calling this function to disassociate a client context and callback from `theHost`, p`clientCB`ass `NULL`.

`clientContext`

A [`CFHostClientContext`](/documentation/CFNetwork/CFHostClientContext) structure whose `info` field will be passed to the callback function specified by `clientCB` when `clientCB` is called. This value must not be `NULL` when setting an association.

    Pass     `NULL`     when disassociating a client context and a callback from a host.

## Return Value

`TRUE` if the association could be set or unset, otherwise `FALSE`.

## Discussion

The callback function specified by `clientCB` will be called when a resolution completes or is cancelled.

### Special Considerations

This function is thread safe.

---

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)