SCNetworkReachability

Overview

The SCNetworkReachability programming interface allows an application to determine the status of a system's current network configuration and the reachability of a target host. A remote host is considered reachable when a data packet, sent by an application into the network stack, can leave the local device. Reachability does not guarantee that the data packet will actually be received by the host.

The SCNetworkReachability programming interface supports a synchronous and an asynchronous model. In the synchronous model, you get the reachability status by calling the SCNetworkReachabilityGetFlags function. In the asynchronous model, you can schedule the SCNetworkReachability object on the run loop of a client object’s thread. The client implements a callback function to receive notifications when the reachability status of a given remote host changes. Note that these functions follow Core Foundation naming conventions. A function that has "Create" or "Copy" in its name returns a reference you must release with the CFRelease function.

For information about detecting and interpreting errors generated by calling these functions, see System Configuration.

Topics

Creating a Reachability Reference

SCNetworkReachabilityCreateWithAddress

Creates a reachability reference to the specified network address.

SCNetworkReachabilityCreateWithAddressPair

Creates a reachability reference to the specified network address.

SCNetworkReachabilityCreateWithName

Creates a reachability reference to the specified network host or node name.

Determining Reachability Status

SCNetworkReachabilityGetFlags

Determines if the specified network target is reachable using the current network configuration.

Preparing to Determine Reachability

SCNetworkReachabilityGetTypeID

Returns the type identifier of all SCNetworkReachability instances.

SCNetworkReachabilitySetCallback

Assigns a client to the specified target, which receives callbacks when the reachability of the target changes.

SCNetworkReachabilityScheduleWithRunLoop

Schedules the specified network target with the specified run loop and mode.

SCNetworkReachabilityUnscheduleFromRunLoop

Unschedules the specified target from the specified run loop and mode.

SCNetworkReachabilitySetDispatchQueue

Schedules callbacks for the specified target on the specified dispatch queue.

Callbacks

SCNetworkReachabilityCallBack

Type of callback function used when the reachability of a network address or name changes.

Data Types

SCNetworkReachabilityRef

The handle to a network address or name.

SCNetworkReachabilityContext

Structure containing user-specified data and callbacks used with SCNetworkReachabilitySetCallback.

Constants

SCNetworkReachabilityFlags

Flags that indicate the reachability of a network node name or address, including whether a connection is required, and whether some user intervention might be required when establishing a connection.