The CFHost API allows you to create instances of the CFHost object that you can use to acquire host information, including names, addresses, and reachability information.


The process of acquiring information about a host is known as resolution. Begin by calling CFHostCreateWithAddress or CFHostCreateWithName to create an instance of a CFHost using an address or a name, respectively. If you want to resolve the host asynchronously. call CFHostSetClient to associate your client context and user-defined callback function with the host. Then call CFHostScheduleWithRunLoop to schedule the host on a run loop.

To start resolution, call CFHostStartInfoResolution. If you set up for asynchronous resolution, CFHostStartInfoResolution returns immediately. Your callback function will be called when resolution is complete. If you didn’t set up for asynchronous resolution, CFHostStartInfoResolution blocks until resolution is complete, an error occurs, or the resolution is cancelled.

When resolution is complete, call CFHostGetAddressing or CFHostGetNames to get an array of known addresses or known names, respectively, for the host. Call CFHostGetReachability to get flags, declared in SystemConfiguration/SCNetwork.h, that describe the reachability of the host.

When you no longer need a CFHost object, call CFHostUnscheduleFromRunLoop and CFHostSetClient to disassociate the host from your user-defined client context and callback function (if it was set up for asynchronous resolution). Then dispose of it.


Creating a host

func CFHostCreateCopy(CFAllocator?, CFHost)

Creates a new host object by copying.

func CFHostCreateWithAddress(CFAllocator?, CFData)

Uses an address to create an instance of a host object.

func CFHostCreateWithName(CFAllocator?, CFString)

Uses a name to create an instance of a host object.

CFHost Functions

func CFHostSetClient(CFHost, CFHostClientCallBack?, UnsafeMutablePointer<CFHostClientContext>?)

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

Getting the CFHost Type ID

func CFHostGetTypeID()

Gets the Core Foundation type identifier for the CFHost opaque type.


typealias CFHostClientCallBack

Defines a pointer to the callback function that is called when an asynchronous resolution of a CFHost completes or an error occurs for an asynchronous CFHost resolution.

Data Types

class CFHost

An opaque reference representing an CFHost object.

struct CFHostClientContext

A structure containing user-defined data and callbacks for CFHost objects.


enum CFHostInfoType

Values indicating the type of data that is to be resolved or the type of data that was resolved.

Error Domains

Error domains specific to CFHost calls.

See Also

Opaque Types


This document describes the CFStream functions for working with FTP connections. It is part of the CFFTP API.


The CFHTTPAuthentication opaque type provides an abstraction of HTTP authentication information.


The CFHTTPMessage opaque type represents an HTTP message.


The CFNetDiagnostics opaque type allows you to diagnose network-related problems.


The CFNetServices API is part of Bonjour, Apple’s implementation of zero-configuration networking (ZEROCONF). The CFNetServices API allows you to register a network service, such as a printer or file server, so that it can be found by name or browsed for by service type and domain. Applications can use the CFNetServices API to discover the services that are available on the network and to find all access information — such as name, IP address, and port number — needed to use each service.