Framework

CFNetwork

Access network services and handle changes in network configurations. Build on abstractions of network protocols to simplify tasks such as working with BSD sockets, administering HTTP and FTP servers, and managing Bonjour services.

Symbols

Errors

CFNetworkErrors

This enumeration contains error codes returned under the error domain kCFErrorDomainCFNetwork.

Error Dictionary Keys

Networking-related keys that may be available in a CFErrorRef object’s userInfo dictionary.

Error Domains

High-level error domains.

Hosts

CFHost

An opaque reference representing an CFHost object.

CFHostInfoType

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

CFHostClientContext

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

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.

func CFHostGetTypeID()

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

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.

Global Proxy Configuration

func CFNetworkCopyProxiesForURL(CFURL, CFDictionary)

Returns the list of proxies that should be used to download a given URL.

func CFNetworkCopyProxiesForAutoConfigurationScript(CFString, CFURL, UnsafeMutablePointer<Unmanaged<CFError>?>?)

Executes a proxy autoconfiguration script to determine the best proxy to use to retrieve a specified URL.

func CFNetworkCopySystemProxySettings()

Returns a CFDictionary containing the current systemwide internet proxy settings.

CFProxyAutoConfigurationResultCallback

Callback function called when a proxy autoconfiguration computation has completed.

Property Keys

Keys for calls to property get/set functions such as CFReadStreamSetProperty(_:_:_:) and CFReadStreamCopyProperty(_:_:).

Proxy Types

Constants that specify the type of proxy.

Global Proxy Settings Constants

Constants for keys in the global proxy settings dictionary returned by CFNetworkCopySystemProxySettings().

HTTP Authentication

CFHTTPAuthentication

An opaque reference representing HTTP authentication information.

func CFHTTPAuthenticationAppliesToRequest(CFHTTPAuthentication, CFHTTPMessage)

Returns a Boolean value that indicates whether a CFHTTPAuthentication object is associated with a CFHTTPMessage object.

func CFHTTPAuthenticationCopyDomains(CFHTTPAuthentication)

Returns an array of domain URLs to which a given CFHTTPAuthentication object can be applied.

func CFHTTPAuthenticationCopyMethod(CFHTTPAuthentication)

Gets the strongest authentication method that will be used when a CFHTTPAuthentication object is applied to a request.

func CFHTTPAuthenticationCopyRealm(CFHTTPAuthentication)

Gets an authentication information’s namespace.

func CFHTTPAuthenticationCreateFromResponse(CFAllocator?, CFHTTPMessage)

Uses an authentication failure response to create a CFHTTPAuthentication object.

func CFHTTPAuthenticationGetTypeID()

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

func CFHTTPAuthenticationIsValid(CFHTTPAuthentication, UnsafeMutablePointer<CFStreamError>?)

Returns a Boolean value that indicates whether a CFHTTPAuthentication object is valid.

func CFHTTPAuthenticationRequiresAccountDomain(CFHTTPAuthentication)

Returns a Boolean value that indicates whether a CFHTTPAuthentication object uses an authentication method that requires an account domain.

func CFHTTPAuthenticationRequiresOrderedRequests(CFHTTPAuthentication)

Returns a Boolean value that indicates whether authentication requests should be made one at a time.

func CFHTTPAuthenticationRequiresUserNameAndPassword(CFHTTPAuthentication)

Returns a Boolean value that indicates whether a CFHTTPAuthentication object uses an authentication method that requires a username and a password.

let kCFHTTPAuthenticationAccountDomain: CFString

Account domain to use for authentication.

let kCFHTTPAuthenticationPassword: CFString

Password to use for authentication.

let kCFHTTPAuthenticationSchemeBasic: CFString

Request the HTTP basic authentication scheme.

let kCFHTTPAuthenticationSchemeDigest: CFString

Request the HTTP digest authentication scheme.

let kCFHTTPAuthenticationSchemeKerberos: CFString

Request the HTTP Kerberos authentication scheme.

let kCFHTTPAuthenticationSchemeNTLM: CFString

Request the HTTP NTLM authentication scheme.

let kCFHTTPAuthenticationSchemeNegotiate: CFString

Request the HTTP Negotiate authentication scheme.

let kCFHTTPAuthenticationSchemeNegotiate2: CFString

Request the HTTP Negotiate v2 authentication scheme.

let kCFHTTPAuthenticationSchemeOAuth1: CFString

Request the HTTP OAuth 1.0 authentication scheme.

let kCFHTTPAuthenticationSchemeXMobileMeAuthToken: CFString

Request the HTTP XMobileMeAuthToken authentication scheme.

let kCFHTTPAuthenticationUsername: CFString

Username to use for authentication.

HTTP Messages

CFHTTPMessage

An opaque reference representing an HTTP message.

func CFHTTPMessageApplyCredentialDictionary(CFHTTPMessage, CFHTTPAuthentication, CFDictionary, UnsafeMutablePointer<CFStreamError>?)

Use a dictionary containing authentication credentials to perform the authentication method specified by a CFHTTPAuthentication object.

func CFHTTPMessageCopyAllHeaderFields(CFHTTPMessage)

Gets all header fields from a CFHTTPMessage object.

func CFHTTPMessageCopyBody(CFHTTPMessage)

Gets the body from a CFHTTPMessage object.

func CFHTTPMessageCopyHeaderFieldValue(CFHTTPMessage, CFString)

Gets the value of a header field from a CFHTTPMessage object.

func CFHTTPMessageCopyRequestMethod(CFHTTPMessage)

Gets the request method from a CFHTTPMessage object.

func CFHTTPMessageCopyRequestURL(CFHTTPMessage)

Gets the URL from a CFHTTPMessage object.

func CFHTTPMessageCopyResponseStatusLine(CFHTTPMessage)

Gets the status line from a CFHTTPMessage object.

func CFHTTPMessageCopyVersion(CFHTTPMessage)

Gets the HTTP version from a CFHTTPMessage object.

func CFHTTPMessageCreateCopy(CFAllocator?, CFHTTPMessage)

Gets a copy of a CFHTTPMessage object.

func CFHTTPMessageCreateEmpty(CFAllocator?, Bool)

Creates and returns a new, empty CFHTTPMessage object.

func CFHTTPMessageCreateRequest(CFAllocator?, CFString, CFURL, CFString)

Creates and returns a CFHTTPMessage object for an HTTP request.

func CFHTTPMessageCreateResponse(CFAllocator?, CFIndex, CFString?, CFString)

Creates and returns a CFHTTPMessage object for an HTTP response.

func CFHTTPMessageGetResponseStatusCode(CFHTTPMessage)

Gets the status code from a CFHTTPMessage object representing an HTTP response.

func CFHTTPMessageGetTypeID()

Returns the Core Foundation type identifier for the CFHTTPMessage opaque type.

func CFHTTPMessageIsHeaderComplete(CFHTTPMessage)

Determines whether a message header is complete.

func CFHTTPMessageIsRequest(CFHTTPMessage)

Returns a boolean indicating whether the CFHTTPMessage is a request or a response.

func CFHTTPMessageSetBody(CFHTTPMessage, CFData)

Sets the body of a CFHTTPMessage object.

func CFHTTPMessageSetHeaderFieldValue(CFHTTPMessage, CFString, CFString?)

Sets the value of a header field in an HTTP message.

let kCFHTTPVersion1_0: CFString

Specifies HTTP version 1.0.

let kCFHTTPVersion1_1: CFString

Specifies HTTP version 1.1.

let kCFHTTPVersion2_0: CFString

FTP

let kCFFTPResourceGroup: CFString

CFDictionary key for getting the CFString containing the name of a group that shares the FTP resource.

Deprecated
let kCFFTPResourceLink: CFString

CFDictionary key for getting the CFString containing the symbolic link information. If the item is a symbolic link, the CFString contains the path to the item that the link references.

Deprecated
let kCFFTPResourceModDate: CFString

CFDictionary key for getting the CFDate containing the last date and time the FTP resource was modified.

Deprecated
let kCFFTPResourceMode: CFString

CFDictionary key for getting the CFNumber containing the access permissions, defined in sys/types.h, of the FTP resource.

Deprecated
let kCFFTPResourceName: CFString

CFDictionary key for getting the CFString containing the name of the FTP resource.

Deprecated
let kCFFTPResourceOwner: CFString

CFDictionary key for getting the CFString containing the name of the owner of the FTP resource.

Deprecated
let kCFFTPResourceSize: CFString

CFDictionary key for getting the CFNumber containing the size in bytes of the FTP resource.

Deprecated
let kCFFTPResourceType: CFString

CFDictionary key for getting the CFNumber containing the type of the FTP resource as defined in sys/dirent.h.

Deprecated

Network Diagnostics

CFNetDiagnostic

An opaque reference representing a CFNetDiagnostic.

CFNetDiagnosticStatusValues

Constants for diagnostic status values.

func CFNetDiagnosticCreateWithStreams(CFAllocator?, CFReadStream?, CFWriteStream?)

Creates a network diagnostic object from a pair of CFStreams.

func CFNetDiagnosticCreateWithURL(CFAllocator, CFURL)

Creates a CFNetDiagnosticRef from a CFURLRef.

func CFNetDiagnosticSetName(CFNetDiagnostic, CFString)

Overrides the displayed application name.

Network Services

CFNetService

An opaque reference representing a CFNetService.

CFNetServiceBrowser

An opaque reference representing a CFNetServiceBrowser.

CFNetServiceBrowserFlags
CFNetServiceMonitor

An opaque reference for a service monitor.

CFNetServiceMonitorType

Record type specifier used to tell a service monitor the type of record changes to watch for.

CFNetServiceClientContext

A structure provided when a CFNetService is associated with a callback function or when a CFNetServiceBrowser is created.

CFNetServiceRegisterFlags
CFNetServicesError

Error codes that may be returned by CFNetServices functions or passed to CFNetServices callback functions.

func CFNetServiceBrowserInvalidate(CFNetServiceBrowser)

Invalidates an instance of a Network Service browser object.

func CFNetServiceBrowserGetTypeID()

Gets the Core Foundation type identifier for the Network Service browser object.

func CFNetServiceBrowserUnscheduleFromRunLoop(CFNetServiceBrowser, CFRunLoop, CFString)

Unschedules a CFNetServiceBrowser from a run loop and mode.

func CFNetServiceCancel(CFNetService)

Cancels a service registration or a service resolution.

func CFNetServiceCreateCopy(CFAllocator?, CFNetService)

Creates a copy of a CFNetService object.

func CFNetServiceCreateDictionaryWithTXTData(CFAllocator?, CFData)

Uses TXT record data to create a dictionary.

func CFNetServiceCreateTXTDataWithDictionary(CFAllocator?, CFDictionary)

Flattens a set of key/value pairs into a CFDataRef suitable for passing to CFNetServiceSetTXTData(_:_:).

func CFNetServiceGetAddressing(CFNetService)

Gets the IP addressing from a CFNetService.

func CFNetServiceGetDomain(CFNetService)

Gets the domain from a CFNetService.

func CFNetServiceGetName(CFNetService)

Gets the name from a CFNetService.

func CFNetServiceGetPortNumber(CFNetService)

This function gets the port number from a CFNetService.

func CFNetServiceGetTXTData(CFNetService)

Queries a network service for the contents of its TXT records.

func CFNetServiceGetTargetHost(CFNetService)

Queries a CFNetService for its target hosts.

func CFNetServiceGetType(CFNetService)

Gets the type from a CFNetService.

func CFNetServiceGetTypeID()

Gets the Core Foundation type identifier for the Network Service object.

func CFNetServiceMonitorGetTypeID()

Gets the Core Foundation type identifier for all CFNetServiceMonitor instances.

func CFNetServiceMonitorInvalidate(CFNetServiceMonitor)

Invalidates an instance of a Network Service monitor object.

func CFNetServiceSetClient(CFNetService, CFNetServiceClientCallBack?, UnsafeMutablePointer<CFNetServiceClientContext>?)

Associates a callback function with a CFNetService or disassociates a callback function from a CFNetService.

func CFNetServiceSetTXTData(CFNetService, CFData)

Sets the TXT record for a CFNetService.

Streams

func CFReadStreamCreateForHTTPRequest(CFAllocator?, CFHTTPMessage)

Creates a read stream for a CFHTTP request message.

Deprecated
func CFReadStreamCreateForStreamedHTTPRequest(CFAllocator?, CFHTTPMessage, CFReadStream)

Creates a read stream for a CFHTTP request message object whose body is too long to keep in memory.

Deprecated
let kCFStreamPropertyHTTPFinalRequest: CFString

HTTP Final Request property. A value of type CFHTTPMessage containing the final message transmitted by the stream after all modifications (including authentication, connection policy, redirects, and so on) have been made. This property cannot be set.

Deprecated
let kCFStreamPropertyHTTPFinalURL: CFString

HTTP Final URL property. A value of type CFURL containing the final HTTP URL. This value differs from the URL in the original HTTP request if an autoredirection occurred. This property cannot be set.

Deprecated
let kCFStreamPropertyHTTPResponseHeader: CFString

HTTP Response Header property. When copied by CFReadStreamCopyProperty(_:_:), the header of an HTTP response message is returned.

Deprecated
let kCFStreamPropertyHTTPShouldAutoredirect: CFString

HTTP Should Auto Redirect property. Set this property to kCFBooleanTrue to enable autoredirection; set this property to kCFBooleanFalse to disable autoredirection.

Deprecated
func CFWriteStreamCreateWithFTPURL(CFAllocator?, CFURL)

Creates an FTP write stream.

Deprecated
func CFReadStreamCreateWithFTPURL(CFAllocator?, CFURL)

Creates an FTP read stream.

Deprecated
let kCFStreamPropertyFTPFileTransferOffset: CFString

FTP File Transfer Offset stream property key for set and copy operations. The value of this property is a CFNumber of type kCFNumberLongLongType representing the file offset at which to start the transfer.

Deprecated
let kCFStreamPropertyFTPPassword: CFString

FTP Password stream property key for set and copy operations. A value of type CFString for storing the login password. Don’t set this property when anonymous FTP is desired.

Deprecated
let kCFStreamPropertyFTPProxy: CFString

FTP Proxy stream property key for set and copy operations. The property is a value of type CFDictionary that holds proxy dictionary key-value pairs. The dictionary returned by SystemConfiguration can also be set as the value of this property.

Deprecated
let kCFStreamPropertyFTPResourceSize: CFString

FTP Resource Size read stream property key copy operations. This property stores a CFNumber of type kCFNumberLongLongType representing the size of a resource in bytes.

Deprecated
let kCFStreamPropertyFTPUsePassiveMode: CFString

FTP Passive Mode stream property key for set and copy operations. Set this property to kCFBooleanTrue to enable passive mode; set this property to kCFBooleanFalse to disable passive mode.

Deprecated
let kCFStreamPropertyFTPUserName: CFString

FTP User Name stream property key for set and copy operations. A value of type CFString for storing the login user name. Don’t set this property when anonymous FTP is desired.

Deprecated
func CFSocketStreamSOCKSGetError(UnsafePointer<CFStreamError>)

This function gets error codes in the kCFStreamErrorDomainSOCKS domain from the CFStreamError returned by a stream operation.

func CFSocketStreamSOCKSGetErrorSubdomain(UnsafePointer<CFStreamError>)

Gets the error subdomain associated with errors in the kCFStreamErrorDomainSOCKS domain from the CFStreamError returned by a stream operation.

let kCFStreamNetworkServiceType: CFString

The type of service for the stream. Providing the service type allows the system to properly handle certain attributes of the stream, including routing and suspension behavior. Most streams do not need to set this property. See Stream Service Types for a list of possible values.

let kCFStreamNetworkServiceTypeBackground: CFString

Specifies that the stream is a background download.

let kCFStreamNetworkServiceTypeCallSignaling: CFString
let kCFStreamNetworkServiceTypeVideo: CFString

Specifies that the stream is providing interactive video data.

let kCFStreamNetworkServiceTypeVoIP: CFString

Specifies that the stream is providing VoIP service.

Deprecated
let kCFStreamNetworkServiceTypeVoice: CFString

Specifies that the stream is providing interactive voice data.

let kCFStreamErrorDomainFTP: Int32

The error code is an FTP error code.

let kCFStreamErrorDomainHTTP: Int32

The error code is an HTTP error code.

let kCFStreamErrorDomainMach: Int32

The error code is a Mach error code defined in mach/error.h.

let kCFStreamErrorDomainNetDB: Int32

The error code is an error code defined in netdb.h.

let kCFStreamErrorDomainNetServices: Int32

The error code is a CFNetService error code. For details, see the CFNetServicesError enumeration.

let kCFStreamErrorDomainSOCKS: Int32

The error code is a SOCKS proxy error.

let kCFStreamErrorDomainSSL: Int32

The error code is an SSL error code as defined in Security/SecureTransport.h.

let kCFStreamErrorDomainSystemConfiguration: Int32

The error code is a system configuration error code as defined in System/ConfigurationSystemConfiguration.h.

let kCFStreamErrorDomainWinSock: CFIndex

When running CFNetwork code on Windows, this domain returns error codes associated with the underlying TCP/IP stack. You should also note that non-networking errors such as ENOMEM are delivered through the POSIX domain. See the header winsock2.h for relevant error codes.

let kCFStreamPropertyConnectionIsCellular: CFString

A boolean value indicating whether the stream is connected over a cellular (WWAN) interface. This is a read-only property, and is false until the connection has been established.

let kCFStreamPropertyNoCellular: CFString

A boolean value indicating that the connection should not be established over a cellular (WWAN) connection. This value can be set only before you open the stream.

let kCFStreamPropertyProxyLocalBypass: CFString

Proxy Local Bypass property key.

let kCFStreamPropertySOCKSPassword: CFString

Constant for the key required to set a user’s password.

let kCFStreamPropertySOCKSProxyHost: CFString

Constant for the SOCKS proxy host key.

let kCFStreamPropertySOCKSProxyPort: CFString

Constant for the SOCKS proxy host port key.

let kCFStreamPropertySOCKSUser: CFString

Constant for the key required to set a user name.

let kCFStreamPropertySOCKSVersion: CFString

Constant for the SOCKS version key.

let kCFStreamPropertySSLContext: CFString
let kCFStreamPropertySSLPeerTrust: CFString

SSL Peer Trust property key for copy operations, which return a SecTrustRef object containing the result of the SSL handshake.

let kCFStreamPropertySSLSettings: CFString

SSL Settings property key for set operations.

let kCFStreamPropertyShouldCloseNativeSocket: CFString

Should Close Native Socket property key.

let kCFStreamPropertySocketExtendedBackgroundIdleMode: CFString
let kCFStreamPropertySocketRemoteHost: CFString

The key’s value is a CFHostRef for the remote host if it is known. If not, its value is NULL.

let kCFStreamPropertySocketRemoteNetService: CFString

The key’s value is a CFNetServiceRef for the remote network service if it is known. If not, its value is NULL.

let kCFStreamPropertySocketSecurityLevel: CFString

Socket Security Level property key.

let kCFStreamSSLCertificates: CFString

Security property key whose value is a CFArray of SecCertificateRefs except for the first element in the array, which is a SecIdentityRef.

let kCFStreamSSLIsServer: CFString

Security property key whose value indicates whether the connection is to act as a server in the SSL process.

let kCFStreamSSLLevel: CFString

Security property key whose value specifies the stream’s security level.

let kCFStreamSSLPeerName: CFString

Security property key whose value overrides the name used for certificate verification.

let kCFStreamSSLValidatesCertificateChain: CFString

Security property key whose value indicates whether the certificate chain should be validated.

let kCFStreamSocketSOCKSVersion4: CFString

Constant used in the kCFStreamSockerSOCKSVersion key to specify SOCKS4 as the SOCKS version for the stream.

let kCFStreamSocketSOCKSVersion5: CFString

Constant used in the kCFStreamSOCKSVersion key to specify SOCKS5 as the SOCKS version for the stream.

let kCFStreamSocketSecurityLevelNegotiatedSSL: CFString

Specifies that the highest level security protocol that can be negotiated be set as the security protocol for a socket stream.

let kCFStreamSocketSecurityLevelNone: CFString

Specifies that no security level be set.

let kCFStreamSocketSecurityLevelSSLv2: CFString

Specifies that SSL version 2 be set as the security protocol for a socket stream.

let kCFStreamSocketSecurityLevelSSLv3: CFString

Specifies that SSL version 3 be set as the security protocol for a socket stream pair.

let kCFStreamSocketSecurityLevelTLSv1: CFString

Specifies that TLS version 1 be set as the security protocol for a socket stream.

CFStreamErrorHTTP

Error codes that a read stream for an HTTP request may return.

CFStreamErrorHTTPAuthentication

Authentication error codes that may be returned when trying to apply authentication to a request.

Secure Sockets (SOCKS) Errors

Error codes returned by the kCFStreamErrorDomainSOCKS error domain.