CFHost

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.

Overview

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.

Symbols

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.

Callbacks

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

CFHost

An opaque reference representing an CFHost object.

CFHostClientContext

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

Constants

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.