<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.0.0",
    "iPadOS: 2.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.4.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/CFNetServiceGetTargetHost(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFNetServiceGetTargetHost"
  },
  "title" : "CFNetServiceGetTargetHost(_:)"
}
-->

# CFNetServiceGetTargetHost(_:)

Queries a CFNetService for its target hosts.

```
func CFNetServiceGetTargetHost(_ theService: CFNetService) -> Unmanaged<CFString>?
```

## Parameters

`theService`

Network service to be queried.

## Return Value

The target host name of the machine providing the service or `NULL` is of the service’s target host is not known. (The target host will not be known if it has not been resolved.)

## Discussion

This function is thread safe, but the target host name is not safe if the service is altered from another thread.

---

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)