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.

Topics

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

CFHostRef

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.

CFHostCancelInfoResolution

Cancels the resolution of a host.

CFHostCreateCopy

Creates a new host object by copying.

CFHostCreateWithAddress

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

CFHostCreateWithName

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

CFHostGetAddressing

Gets the addresses from a host.

CFHostGetNames

Gets the names from a CFHost.

CFHostGetReachability

Gets reachability information from a host.

CFHostGetTypeID

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

CFHostScheduleWithRunLoop

Schedules a CFHost on a run loop.

CFHostSetClient

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

CFHostStartInfoResolution

Starts resolution for a host object.

CFHostUnscheduleFromRunLoop

Unschedules a CFHost from a run loop.

Global Proxy Configuration

CFNetworkCopyProxiesForURL

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

CFNetworkCopyProxiesForAutoConfigurationScript

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

CFNetworkExecuteProxyAutoConfigurationScript

Downloads a proxy autoconfiguration script and executes it.

CFNetworkExecuteProxyAutoConfigurationURL

Downloads a proxy autoconfiguration script and executes it.

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

CFHTTPAuthenticationRef

An opaque reference representing HTTP authentication information.

CFHTTPAuthenticationAppliesToRequest

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

CFHTTPAuthenticationCopyDomains

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

CFHTTPAuthenticationCopyMethod

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

CFHTTPAuthenticationCopyRealm

Gets an authentication information’s namespace.

CFHTTPAuthenticationCreateFromResponse

Uses an authentication failure response to create a CFHTTPAuthentication object.

CFHTTPAuthenticationGetTypeID

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

CFHTTPAuthenticationIsValid

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

CFHTTPAuthenticationRequiresAccountDomain

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

CFHTTPAuthenticationRequiresOrderedRequests

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

CFHTTPAuthenticationRequiresUserNameAndPassword

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

kCFHTTPAuthenticationAccountDomain

Account domain to use for authentication.

kCFHTTPAuthenticationPassword

Password to use for authentication.

kCFHTTPAuthenticationSchemeBasic

Request the HTTP basic authentication scheme.

kCFHTTPAuthenticationSchemeDigest

Request the HTTP digest authentication scheme.

kCFHTTPAuthenticationSchemeKerberos

Request the HTTP Kerberos authentication scheme.

kCFHTTPAuthenticationSchemeNTLM

Request the HTTP NTLM authentication scheme.

kCFHTTPAuthenticationSchemeNegotiate

Request the HTTP Negotiate authentication scheme.

kCFHTTPAuthenticationSchemeNegotiate2

Request the HTTP Negotiate v2 authentication scheme.

kCFHTTPAuthenticationSchemeXMobileMeAuthToken

Request the HTTP XMobileMeAuthToken authentication scheme.

kCFHTTPAuthenticationUsername

Username to use for authentication.

HTTP Messages

CFHTTPMessageRef

An opaque reference representing an HTTP message.

CFHTTPMessageAddAuthentication

Adds authentication information to a request.

CFHTTPMessageAppendBytes

Appends data to a CFHTTPMessage object.

CFHTTPMessageApplyCredentialDictionary

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

CFHTTPMessageApplyCredentials

Performs the authentication method specified by a CFHTTPAuthentication object.

CFHTTPMessageCopyAllHeaderFields

Gets all header fields from a CFHTTPMessage object.

CFHTTPMessageCopyBody

Gets the body from a CFHTTPMessage object.

CFHTTPMessageCopyHeaderFieldValue

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

CFHTTPMessageCopyRequestMethod

Gets the request method from a CFHTTPMessage object.

CFHTTPMessageCopyRequestURL

Gets the URL from a CFHTTPMessage object.

CFHTTPMessageCopyResponseStatusLine

Gets the status line from a CFHTTPMessage object.

CFHTTPMessageCopySerializedMessage

Serializes a CFHTTPMessage object.

CFHTTPMessageCopyVersion

Gets the HTTP version from a CFHTTPMessage object.

CFHTTPMessageCreateCopy

Gets a copy of a CFHTTPMessage object.

CFHTTPMessageCreateEmpty

Creates and returns a new, empty CFHTTPMessage object.

CFHTTPMessageCreateRequest

Creates and returns a CFHTTPMessage object for an HTTP request.

CFHTTPMessageCreateResponse

Creates and returns a CFHTTPMessage object for an HTTP response.

CFHTTPMessageGetResponseStatusCode

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

CFHTTPMessageGetTypeID

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

CFHTTPMessageIsHeaderComplete

Determines whether a message header is complete.

CFHTTPMessageIsRequest

Returns a Boolean indicating whether the HTTP message is a request or a response.

CFHTTPMessageSetBody

Sets the body of a CFHTTPMessage object.

CFHTTPMessageSetHeaderFieldValue

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

kCFHTTPVersion1_0

Specifies HTTP version 1.0.

kCFHTTPVersion1_1

Specifies HTTP version 1.1.

FTP

CFFTPCreateParsedResourceListing

Parses an FTP listing to a dictionary.

Deprecated
kCFFTPResourceGroup

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

Deprecated
kCFFTPResourceLink

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
kCFFTPResourceModDate

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

Deprecated
kCFFTPResourceMode

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

Deprecated
kCFFTPResourceName

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

Deprecated
kCFFTPResourceOwner

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

Deprecated
kCFFTPResourceSize

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

Deprecated
kCFFTPResourceType

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

Deprecated

Network Diagnostics

CFNetDiagnosticRef

An opaque reference representing a CFNetDiagnostic.

CFNetDiagnosticStatusValues

Constants for diagnostic status values.

Deprecated
CFNetDiagnosticCopyNetworkStatusPassively

Gets a network status value.

Deprecated
CFNetDiagnosticCreateWithStreams

Creates a network diagnostic object from a pair of CFStreams.

Deprecated
CFNetDiagnosticCreateWithURL

Creates a CFNetDiagnosticRef from a CFURLRef.

Deprecated
CFNetDiagnosticDiagnoseProblemInteractively

Opens a Network Diagnostics window.

Deprecated
CFNetDiagnosticSetName

Overrides the displayed application name.

Deprecated

Network Services

CFNetServiceRef

An opaque reference representing a CFNetService.

CFNetServiceBrowserRef

An opaque reference representing a CFNetServiceBrowser.

CFNetServiceMonitorRef

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.

CFNetServicesError

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

CFNetServiceBrowserInvalidate

Invalidates an instance of a Network Service browser object.

CFNetServiceBrowserScheduleWithRunLoop

Schedules a CFNetServiceBrowser on a run loop.

CFNetServiceBrowserCreate

Creates an instance of a Network Service browser object.

CFNetServiceBrowserGetTypeID

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

CFNetServiceBrowserSearchForServices

Searches a domain for services of a specified type.

CFNetServiceBrowserStopSearch

Stops a search for domains or services.

CFNetServiceBrowserUnscheduleFromRunLoop

Unschedules a CFNetServiceBrowser from a run loop and mode.

CFNetServiceCancel

Cancels a service registration or a service resolution.

CFNetServiceCreate

Creates an instance of a Network Service object.

CFNetServiceCreateCopy

Creates a copy of a CFNetService object.

CFNetServiceCreateDictionaryWithTXTData

Uses TXT record data to create a dictionary.

CFNetServiceCreateTXTDataWithDictionary

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

CFNetServiceGetAddressing

Gets the IP addressing from a CFNetService.

CFNetServiceGetDomain

Gets the domain from a CFNetService.

CFNetServiceGetName

Gets the name from a CFNetService.

CFNetServiceGetPortNumber

This function gets the port number from a CFNetService.

CFNetServiceGetTXTData

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

CFNetServiceGetTargetHost

Queries a CFNetService for its target hosts.

CFNetServiceGetType

Gets the type from a CFNetService.

CFNetServiceGetTypeID

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

CFNetServiceMonitorCreate

Creates an instance of a NetServiceMonitor object that watches for record changes.

CFNetServiceMonitorGetTypeID

Gets the Core Foundation type identifier for all CFNetServiceMonitor instances.

CFNetServiceMonitorInvalidate

Invalidates an instance of a Network Service monitor object.

CFNetServiceMonitorScheduleWithRunLoop

Schedules a CFNetServiceMonitor on a run loop.

CFNetServiceMonitorStart

Starts monitoring.

CFNetServiceMonitorStop

Stops a CFNetServiceMonitor.

CFNetServiceMonitorUnscheduleFromRunLoop

Unschedules a CFNetServiceMonitor from a run loop.

CFNetServiceRegister

Makes a CFNetService available on the network.

Deprecated
CFNetServiceRegisterWithOptions

Makes a CFNetService available on the network.

CFNetServiceResolve

This function updates the specified CFNetService with the IP address or addresses associated with the service. Call CFNetServiceGetAddressing to get the addresses.

Deprecated
CFNetServiceResolveWithTimeout

Gets the IP address or addresses for a CFNetService.

CFNetServiceSetClient

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

CFNetServiceSetTXTData

Sets the TXT record for a CFNetService.

CFNetServiceUnscheduleFromRunLoop

Unschedules a CFNetService from a run loop.

CFNetServiceScheduleWithRunLoop

Schedules a CFNetService on a run loop.

Streams

CFReadStreamCreateForHTTPRequest

Creates a read stream for a CFHTTP request message.

Deprecated
CFReadStreamCreateForStreamedHTTPRequest

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

Deprecated
kCFStreamPropertyHTTPFinalRequest

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
kCFStreamPropertyHTTPFinalURL

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
kCFStreamPropertyHTTPResponseHeader

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

Deprecated
kCFStreamPropertyHTTPShouldAutoredirect

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

Deprecated
CFWriteStreamCreateWithFTPURL

Creates an FTP write stream.

Deprecated
CFReadStreamCreateWithFTPURL

Creates an FTP read stream.

Deprecated
kCFStreamPropertyFTPFileTransferOffset

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
kCFStreamPropertyFTPPassword

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
kCFStreamPropertyFTPProxy

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
kCFStreamPropertyFTPResourceSize

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
kCFStreamPropertyFTPUsePassiveMode

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
kCFStreamPropertyFTPUserName

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
CFSocketStreamSOCKSGetError

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

CFSocketStreamSOCKSGetErrorSubdomain

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

CFStreamCreatePairWithSocketToCFHost

Creates readable and writable streams connected to a given CFHost object.

CFStreamCreatePairWithSocketToNetService

Creates a pair of streams for a CFNetService.

kCFStreamNetworkServiceType

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.

kCFStreamNetworkServiceTypeBackground

Specifies that the stream is a background download.

kCFStreamNetworkServiceTypeVideo

Specifies that the stream is providing interactive video data.

kCFStreamNetworkServiceTypeVoIP

Specifies that the stream is providing VoIP service.

Deprecated
kCFStreamNetworkServiceTypeVoice

Specifies that the stream is providing interactive voice data.

kCFStreamErrorDomainFTP

The error code is an FTP error code.

kCFStreamErrorDomainHTTP

The error code is an HTTP error code.

kCFStreamErrorDomainMach

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

kCFStreamErrorDomainNetDB

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

kCFStreamErrorDomainNetServices

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

kCFStreamErrorDomainSOCKS

The error code is a SOCKS proxy error.

kCFStreamErrorDomainSSL

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

kCFStreamErrorDomainSystemConfiguration

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

kCFStreamErrorDomainWinSock

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.

kCFStreamPropertyConnectionIsCellular

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.

kCFStreamPropertyNoCellular

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

kCFStreamPropertyProxyLocalBypass

Proxy Local Bypass property key.

kCFStreamPropertySOCKSPassword

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

kCFStreamPropertySOCKSProxy

SOCKS proxy property key.

kCFStreamPropertySOCKSProxyHost

Constant for the SOCKS proxy host key.

kCFStreamPropertySOCKSProxyPort

Constant for the SOCKS proxy host port key.

kCFStreamPropertySOCKSUser

Constant for the key required to set a user name.

kCFStreamPropertySOCKSVersion

Constant for the SOCKS version key.

kCFStreamPropertySSLPeerCertificates

SSL Peer Certificates property key for copy operations, which return a CFArray object containing SecCertificateRef objects.

Deprecated
kCFStreamPropertySSLPeerTrust

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

kCFStreamPropertySSLSettings

SSL Settings property key for set operations.

kCFStreamPropertyShouldCloseNativeSocket

Should Close Native Socket property key.

kCFStreamPropertySocketRemoteHost

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

kCFStreamPropertySocketRemoteNetService

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

kCFStreamPropertySocketSecurityLevel

Socket Security Level property key.

kCFStreamSSLAllowsAnyRoot

Security property key whose value indicates whether root certificates should be allowed.

Deprecated
kCFStreamSSLAllowsExpiredCertificates

Security property key whose value indicates whether expired certificates are allowed.

Deprecated
kCFStreamSSLAllowsExpiredRoots

Security property whose value indicates whether expired root certificates are allowed.

Deprecated
kCFStreamSSLCertificates

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

kCFStreamSSLIsServer

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

kCFStreamSSLLevel

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

kCFStreamSSLPeerName

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

kCFStreamSSLValidatesCertificateChain

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

kCFStreamSocketSOCKSVersion4

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

kCFStreamSocketSOCKSVersion5

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

kCFStreamSocketSecurityLevelNegotiatedSSL

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

kCFStreamSocketSecurityLevelNone

Specifies that no security level be set.

kCFStreamSocketSecurityLevelSSLv2

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

Deprecated
kCFStreamSocketSecurityLevelSSLv3

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

Deprecated
kCFStreamSocketSecurityLevelTLSv1

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software