The SCNetworkConnection programming interface contains functions that allow an application to control connection-oriented services defined in the system and get connection-status information. Note that these functions allow you to control and get information about existing services only. If you need to create, change, or remove services, you should use the SCNetworkConfiguration programming interface instead.


Getting Connection-Status Information

func SCNetworkConnectionGetTypeID() -> CFTypeID

Returns the type identifier of all SCNetworkConnection instances.

func SCNetworkConnectionCopyServiceID(SCNetworkConnection) -> CFString?

Returns the service ID associated with the specified network connection.

func SCNetworkConnectionCopyStatistics(SCNetworkConnection) -> CFDictionary?

Returns the statistics of the specified connection.

func SCNetworkConnectionCopyUserOptions(SCNetworkConnection) -> CFDictionary?

Gets the user options used to start the specified connection.

Starting and Stopping a Connection

func SCNetworkConnectionStart(SCNetworkConnection, CFDictionary?, Bool) -> Bool

Starts the connection process for the specified network connection.

func SCNetworkConnectionStop(SCNetworkConnection, Bool) -> Bool

Stops the connection process for the specified network connection.

Scheduling a Connection Reference on a Run Loop

func SCNetworkConnectionScheduleWithRunLoop(SCNetworkConnection, CFRunLoop, CFString) -> Bool

Schedules the specified connection with the specified run loop.

func SCNetworkConnectionUnscheduleFromRunLoop(SCNetworkConnection, CFRunLoop, CFString) -> Bool

Unschedules the specified connection from the specified run loop.

Creating a Connection Reference

func SCNetworkConnectionCreateWithServiceID(CFAllocator?, CFString, SCNetworkConnectionCallBack?, UnsafeMutablePointer<SCNetworkConnectionContext>?) -> SCNetworkConnection?

Creates a new connection reference to use for getting the status or for connecting or disconnecting the associated service.

Specifying a Dispatch Queue and Enabling Notifications

func SCNetworkConnectionSetDispatchQueue(SCNetworkConnection, DispatchQueue?) -> Bool

Specifies a dispatch queue to use for the connection’s callback function and enables notifications.

Data Types

class SCNetworkConnection

The handle to manage a connection-oriented service.

typealias SCNetworkConnectionCallBack

The type of callback function used when a status event is delivered.

struct SCNetworkConnectionContext

A structure containing user-specified data and callbacks for a network connection.


enum SCNetworkConnectionStatus

The current status of the network connection.

enum SCNetworkConnectionPPPStatus

The PPP-specific status of the network connection.

Statistics Dictionary Keys

Keys associated with values in the statistics dictionary.