iOS Developer Library

Developer

CoreServices Framework Reference CFNetwork Error Codes Reference

Options
Deployment Target:

On This Page
Language:

CFNetwork Error Codes Reference

Many functions in the CFNetwork API return error codes to indicate the cause of a failure. This document explains these error codes.

Constants

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

    Declaration

    Swift

    enum CFNetworkErrors : Int32 { case CFHostErrorHostNotFound case CFHostErrorUnknown case CFSOCKSErrorUnknownClientVersion case CFSOCKSErrorUnsupportedServerVersion case CFSOCKS4ErrorRequestFailed case CFSOCKS4ErrorIdentdFailed case CFSOCKS4ErrorIdConflict case CFSOCKS4ErrorUnknownStatusCode case CFSOCKS5ErrorBadState case CFSOCKS5ErrorBadResponseAddr case CFSOCKS5ErrorBadCredentials case CFSOCKS5ErrorUnsupportedNegotiationMethod case CFSOCKS5ErrorNoAcceptableMethod case CFFTPErrorUnexpectedStatusCode case CFErrorHTTPAuthenticationTypeUnsupported case CFErrorHTTPBadCredentials case CFErrorHTTPConnectionLost case CFErrorHTTPParseFailure case CFErrorHTTPRedirectionLoopDetected case CFErrorHTTPBadURL case CFErrorHTTPProxyConnectionFailure case CFErrorHTTPBadProxyCredentials case CFErrorPACFileError case CFErrorPACFileAuth case CFErrorHTTPSProxyConnectionFailure case CFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod case CFURLErrorBackgroundSessionInUseByAnotherProcess case CFURLErrorBackgroundSessionWasDisconnected case CFURLErrorUnknown case CFURLErrorCancelled case CFURLErrorBadURL case CFURLErrorTimedOut case CFURLErrorUnsupportedURL case CFURLErrorCannotFindHost case CFURLErrorCannotConnectToHost case CFURLErrorNetworkConnectionLost case CFURLErrorDNSLookupFailed case CFURLErrorHTTPTooManyRedirects case CFURLErrorResourceUnavailable case CFURLErrorNotConnectedToInternet case CFURLErrorRedirectToNonExistentLocation case CFURLErrorBadServerResponse case CFURLErrorUserCancelledAuthentication case CFURLErrorUserAuthenticationRequired case CFURLErrorZeroByteResource case CFURLErrorCannotDecodeRawData case CFURLErrorCannotDecodeContentData case CFURLErrorCannotParseResponse case CFURLErrorInternationalRoamingOff case CFURLErrorCallIsActive case CFURLErrorDataNotAllowed case CFURLErrorRequestBodyStreamExhausted case CFURLErrorFileDoesNotExist case CFURLErrorFileIsDirectory case CFURLErrorNoPermissionsToReadFile case CFURLErrorDataLengthExceedsMaximum case CFURLErrorSecureConnectionFailed case CFURLErrorServerCertificateHasBadDate case CFURLErrorServerCertificateUntrusted case CFURLErrorServerCertificateHasUnknownRoot case CFURLErrorServerCertificateNotYetValid case CFURLErrorClientCertificateRejected case CFURLErrorClientCertificateRequired case CFURLErrorCannotLoadFromNetwork case CFURLErrorCannotCreateFile case CFURLErrorCannotOpenFile case CFURLErrorCannotCloseFile case CFURLErrorCannotWriteToFile case CFURLErrorCannotRemoveFile case CFURLErrorCannotMoveFile case CFURLErrorDownloadDecodingFailedMidStream case CFURLErrorDownloadDecodingFailedToComplete case CFHTTPCookieCannotParseCookieFile case CFNetServiceErrorUnknown case CFNetServiceErrorCollision case CFNetServiceErrorNotFound case CFNetServiceErrorInProgress case CFNetServiceErrorBadArgument case CFNetServiceErrorCancel case CFNetServiceErrorInvalid case CFNetServiceErrorTimeout case CFNetServiceErrorDNSServiceFailure }

    Objective-C

    enum CFNetworkErrors { kCFHostErrorHostNotFound = 1, kCFHostErrorUnknown = 2, /* SOCKS errors */ kCFSOCKSErrorUnknownClientVersion = 100, kCFSOCKSErrorUnsupportedServerVersion = 101, /* SOCKS4-specific errors */ kCFSOCKS4ErrorRequestFailed = 110, kCFSOCKS4ErrorIdentdFailed = 111, kCFSOCKS4ErrorIdConflict = 112, kCFSOCKS4ErrorUnknownStatusCode = 113, /* SOCKS5-specific errors */ kCFSOCKS5ErrorBadState = 120, kCFSOCKS5ErrorBadResponseAddr = 121, kCFSOCKS5ErrorBadCredentials = 122, kCFSOCKS5ErrorUnsupportedNegotiationMethod = 123, kCFSOCKS5ErrorNoAcceptableMethod = 124, /* FTP errors */ kCFFTPErrorUnexpectedStatusCode = 200, /* HTTP errors */ kCFErrorHTTPAuthenticationTypeUnsupported = 300, kCFErrorHTTPBadCredentials = 301, kCFErrorHTTPConnectionLost = 302, kCFErrorHTTPParseFailure = 303, kCFErrorHTTPRedirectionLoopDetected = 304, kCFErrorHTTPBadURL = 305, kCFErrorHTTPProxyConnectionFailure = 306, kCFErrorHTTPBadProxyCredentials = 307, kCFErrorPACFileError = 308, kCFErrorPACFileAuth = 309, kCFErrorHTTPSProxyConnectionFailure = 310, kCFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod = 311, /* CFURL and CFURLConnection Errors */ kCFURLErrorUnknown = -998, kCFURLErrorCancelled = -999, kCFURLErrorBadURL = -1000, kCFURLErrorTimedOut = -1001, kCFURLErrorUnsupportedURL = -1002, kCFURLErrorCannotFindHost = -1003, kCFURLErrorCannotConnectToHost = -1004, kCFURLErrorNetworkConnectionLost = -1005, kCFURLErrorDNSLookupFailed = -1006, kCFURLErrorHTTPTooManyRedirects = -1007, kCFURLErrorResourceUnavailable = -1008, kCFURLErrorNotConnectedToInternet = -1009, kCFURLErrorRedirectToNonExistentLocation = -1010, kCFURLErrorBadServerResponse = -1011, kCFURLErrorUserCancelledAuthentication = -1012, kCFURLErrorUserAuthenticationRequired = -1013, kCFURLErrorZeroByteResource = -1014, kCFURLErrorCannotDecodeRawData = -1015, kCFURLErrorCannotDecodeContentData = -1016, kCFURLErrorCannotParseResponse = -1017, kCFURLErrorInternationalRoamingOff = -1018, kCFURLErrorCallIsActive = -1019, kCFURLErrorDataNotAllowed = -1020, kCFURLErrorRequestBodyStreamExhausted = -1021, kCFURLErrorFileDoesNotExist = -1100, kCFURLErrorFileIsDirectory = -1101, kCFURLErrorNoPermissionsToReadFile = -1102, kCFURLErrorDataLengthExceedsMaximum = -1103, /* SSL errors */ kCFURLErrorSecureConnectionFailed = -1200, kCFURLErrorServerCertificateHasBadDate = -1201, kCFURLErrorServerCertificateUntrusted = -1202, kCFURLErrorServerCertificateHasUnknownRoot = -1203, kCFURLErrorServerCertificateNotYetValid = -1204, kCFURLErrorClientCertificateRejected = -1205, kCFURLErrorClientCertificateRequired = -1206, kCFURLErrorCannotLoadFromNetwork = -2000, /* Download and file I/O errors */ kCFURLErrorCannotCreateFile = -3000, kCFURLErrorCannotOpenFile = -3001, kCFURLErrorCannotCloseFile = -3002, kCFURLErrorCannotWriteToFile = -3003, kCFURLErrorCannotRemoveFile = -3004, kCFURLErrorCannotMoveFile = -3005, kCFURLErrorDownloadDecodingFailedMidStream = -3006, kCFURLErrorDownloadDecodingFailedToComplete = -3007, /* Cookie errors */ kCFHTTPCookieCannotParseCookieFile = -4000, /* Errors originating from CFNetServices */ kCFNetServiceErrorUnknown = -72000L, kCFNetServiceErrorCollision = -72001L, kCFNetServiceErrorNotFound = -72002L, kCFNetServiceErrorInProgress = -72003L, kCFNetServiceErrorBadArgument = -72004L, kCFNetServiceErrorCancel = -72005L, kCFNetServiceErrorInvalid = -72006L, kCFNetServiceErrorTimeout = -72007L, kCFNetServiceErrorDNSServiceFailure = -73000L, }; typedef enum CFNetworkErrors CFNetworkErrors;

    Constants

    • CFHostErrorHostNotFound

      kCFHostErrorHostNotFound

      Indicates that the DNS lookup failed.

      Available in iOS 2.0 and later.

    • CFHostErrorUnknown

      kCFHostErrorUnknown

      An unknown error occurred (a name server failure, for example). For additional information, you can query the kCFGetAddrInfoFailureKey key to obtain the value returned by getaddrinfo and look up the value in /usr/include/netdb.h.

      Available in iOS 2.0 and later.

    • CFSOCKSErrorUnknownClientVersion

      kCFSOCKSErrorUnknownClientVersion

      The SOCKS server rejected access because it does not support connections with the requested SOCKS version. SOCKS client version. You can query the kCFSOCKSVersionKey key to find out what version the server requested.

      Available in iOS 2.0 and later.

    • CFSOCKSErrorUnsupportedServerVersion

      kCFSOCKSErrorUnsupportedServerVersion

      The version of SOCKS requested by the server is not supported. You can query the kCFSOCKSVersionKey key to find out what version the server requested.

      Available in iOS 2.0 and later.

    • CFSOCKS4ErrorRequestFailed

      kCFSOCKS4ErrorRequestFailed

      Request rejected by the server or request failed. This error is specific to SOCKS4.

      Available in iOS 2.0 and later.

    • CFSOCKS4ErrorIdentdFailed

      kCFSOCKS4ErrorIdentdFailed

      Request rejected by the server because it could not connect to the identd daemon on the client. This error is specific to SOCKS4.

      Available in iOS 2.0 and later.

    • CFSOCKS4ErrorIdConflict

      kCFSOCKS4ErrorIdConflict

      Request rejected by the server because the client program and the identd daemon reported different user IDs. This error is specific to SOCKS4.

      Available in iOS 2.0 and later.

    • CFSOCKS4ErrorUnknownStatusCode

      kCFSOCKS4ErrorUnknownStatusCode

      The status code returned by the server is unknown. This error is specific to SOCKS4.

      Available in iOS 2.0 and later.

    • CFSOCKS5ErrorBadState

      kCFSOCKS5ErrorBadState

      The stream is not in a state that allows the requested operation.

      Available in iOS 2.0 and later.

    • CFSOCKS5ErrorBadResponseAddr

      kCFSOCKS5ErrorBadResponseAddr

      The address type returned is not supported

      Available in iOS 2.0 and later.

    • CFSOCKS5ErrorBadCredentials

      kCFSOCKS5ErrorBadCredentials

      The SOCKS server refused the client connection because of bad login credentials.

      Available in iOS 2.0 and later.

    • CFSOCKS5ErrorUnsupportedNegotiationMethod

      kCFSOCKS5ErrorUnsupportedNegotiationMethod

      The requested method is not supported. You can query the kCFSOCKSNegotiationMethodKey key to find out which method the server requested.

      Available in iOS 2.0 and later.

    • CFSOCKS5ErrorNoAcceptableMethod

      kCFSOCKS5ErrorNoAcceptableMethod

      The client and server could not find a mutually agreeable authentication method.

      Available in iOS 2.0 and later.

    • CFFTPErrorUnexpectedStatusCode

      kCFFTPErrorUnexpectedStatusCode

      The server returned an unexpected status code.

      Available in iOS 2.0 and later.

    • CFErrorHTTPAuthenticationTypeUnsupported

      kCFErrorHTTPAuthenticationTypeUnsupported

      The client and server could not agree on a supported authentication type.

      Available in iOS 2.0 and later.

    • CFErrorHTTPBadCredentials

      kCFErrorHTTPBadCredentials

      The credentials provided for an authenticated connection were rejected by the server.

      Available in iOS 2.0 and later.

    • CFErrorHTTPConnectionLost

      kCFErrorHTTPConnectionLost

      The connection to the server was dropped. This usually indicates a highly overloaded server.

      Available in iOS 2.0 and later.

    • CFErrorHTTPParseFailure

      kCFErrorHTTPParseFailure

      The HTTP server response could not be parsed.

      Available in iOS 2.0 and later.

    • CFErrorHTTPRedirectionLoopDetected

      kCFErrorHTTPRedirectionLoopDetected

      Too many HTTP redirects occurred before reaching a page that did not redirect the client to another page. This usually indicates a redirect loop.

      Available in iOS 2.0 and later.

    • CFErrorHTTPBadURL

      kCFErrorHTTPBadURL

      The requested URL could not be retrieved.

      Available in iOS 2.0 and later.

    • CFErrorHTTPProxyConnectionFailure

      kCFErrorHTTPProxyConnectionFailure

      A connection could not be established to the HTTP proxy.

      Available in iOS 2.0 and later.

    • CFErrorHTTPBadProxyCredentials

      kCFErrorHTTPBadProxyCredentials

      The authentication credentials provided for logging into the proxy were rejected.

      Available in iOS 2.0 and later.

    • CFErrorPACFileError

      kCFErrorPACFileError

      An error occurred with the proxy autoconfiguration file.

      Available in iOS 2.0 and later.

    • CFErrorPACFileAuth

      kCFErrorPACFileAuth

      The authentication credentials provided by the proxy autoconfiguration file were rejected.

      Available in iOS 3.0 and later.

    • CFErrorHTTPSProxyConnectionFailure

      kCFErrorHTTPSProxyConnectionFailure

      A connection could not be established to the HTTPS proxy.

      Available in iOS 3.0 and later.

    • CFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod

      kCFStreamErrorHTTPSProxyFailureUnexpectedResponseToCONNECTMethod

      The HTTPS proxy returned an unexpected status code, such as a 3xx redirect.

      Available in iOS 6.0 and later.

    • CFURLErrorUnknown

      kCFURLErrorUnknown

      An unknown error occurred.

      Available in iOS 3.0 and later.

    • CFURLErrorCancelled

      kCFURLErrorCancelled

      The connection was cancelled.

      Available in iOS 3.0 and later.

    • CFURLErrorBadURL

      kCFURLErrorBadURL

      The connection failed due to a malformed URL.

      Available in iOS 3.0 and later.

    • CFURLErrorTimedOut

      kCFURLErrorTimedOut

      The connection timed out.

      Available in iOS 3.0 and later.

    • CFURLErrorUnsupportedURL

      kCFURLErrorUnsupportedURL

      The connection failed due to an unsupported URL scheme.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotFindHost

      kCFURLErrorCannotFindHost

      The connection failed because the host could not be found.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotConnectToHost

      kCFURLErrorCannotConnectToHost

      The connection failed because a connection cannot be made to the host.

      Available in iOS 3.0 and later.

    • CFURLErrorNetworkConnectionLost

      kCFURLErrorNetworkConnectionLost

      The connection failed because the network connection was lost.

      Available in iOS 3.0 and later.

    • CFURLErrorDNSLookupFailed

      kCFURLErrorDNSLookupFailed

      The connection failed because the DNS lookup failed.

      Available in iOS 3.0 and later.

    • CFURLErrorHTTPTooManyRedirects

      kCFURLErrorHTTPTooManyRedirects

      The HTTP connection failed due to too many redirects.

      Available in iOS 3.0 and later.

    • CFURLErrorResourceUnavailable

      kCFURLErrorResourceUnavailable

      The connection’s resource is unavailable.

      Available in iOS 3.0 and later.

    • CFURLErrorNotConnectedToInternet

      kCFURLErrorNotConnectedToInternet

      The connection failed because the device is not connected to the internet.

      Available in iOS 3.0 and later.

    • CFURLErrorRedirectToNonExistentLocation

      kCFURLErrorRedirectToNonExistentLocation

      The connection was redirected to a nonexistent location.

      Available in iOS 3.0 and later.

    • CFURLErrorBadServerResponse

      kCFURLErrorBadServerResponse

      The connection received an invalid server response.

      Available in iOS 3.0 and later.

    • CFURLErrorUserCancelledAuthentication

      kCFURLErrorUserCancelledAuthentication

      The connection failed because the user cancelled required authentication.

      Available in iOS 3.0 and later.

    • CFURLErrorUserAuthenticationRequired

      kCFURLErrorUserAuthenticationRequired

      The connection failed because authentication is required.

      Available in iOS 3.0 and later.

    • CFURLErrorZeroByteResource

      kCFURLErrorZeroByteResource

      The resource retrieved by the connection is zero bytes.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotDecodeRawData

      kCFURLErrorCannotDecodeRawData

      The connection cannot decode data encoded with a known content encoding.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotDecodeContentData

      kCFURLErrorCannotDecodeContentData

      The connection cannot decode data encoded with an unknown content encoding.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotParseResponse

      kCFURLErrorCannotParseResponse

      The connection cannot parse the server’s response.

      Available in iOS 3.0 and later.

    • CFURLErrorInternationalRoamingOff

      kCFURLErrorInternationalRoamingOff

      The connection failed because international roaming is disabled on the device.

      Available in iOS 3.0 and later.

    • CFURLErrorCallIsActive

      kCFURLErrorCallIsActive

      The connection failed because a call is active.

      Available in iOS 3.0 and later.

    • CFURLErrorDataNotAllowed

      kCFURLErrorDataNotAllowed

      The connection failed because data use is currently not allowed on the device.

      Available in iOS 3.0 and later.

    • CFURLErrorRequestBodyStreamExhausted

      kCFURLErrorRequestBodyStreamExhausted

      The connection failed because its request’s body stream was exhausted.

      Available in iOS 3.0 and later.

    • CFURLErrorFileDoesNotExist

      kCFURLErrorFileDoesNotExist

      The file operation failed because the file does not exist.

      Available in iOS 3.0 and later.

    • CFURLErrorFileIsDirectory

      kCFURLErrorFileIsDirectory

      The file operation failed because the file is a directory.

      Available in iOS 3.0 and later.

    • CFURLErrorNoPermissionsToReadFile

      kCFURLErrorNoPermissionsToReadFile

      The file operation failed because it does not have permission to read the file.

      Available in iOS 3.0 and later.

    • CFURLErrorDataLengthExceedsMaximum

      kCFURLErrorDataLengthExceedsMaximum

      The file operation failed because the file is too large.

      Available in iOS 3.0 and later.

    • CFURLErrorSecureConnectionFailed

      kCFURLErrorSecureConnectionFailed

      The secure connection failed for an unknown reason.

      Available in iOS 3.0 and later.

    • CFURLErrorServerCertificateHasBadDate

      kCFURLErrorServerCertificateHasBadDate

      The secure connection failed because the server’s certificate has an invalid date.

      Available in iOS 3.0 and later.

    • CFURLErrorServerCertificateUntrusted

      kCFURLErrorServerCertificateUntrusted

      The secure connection failed because the server’s certificate is not trusted.

      Available in iOS 3.0 and later.

    • CFURLErrorServerCertificateHasUnknownRoot

      kCFURLErrorServerCertificateHasUnknownRoot

      The secure connection failed because the server’s certificate has an unknown root.

      Available in iOS 3.0 and later.

    • CFURLErrorServerCertificateNotYetValid

      kCFURLErrorServerCertificateNotYetValid

      The secure connection failed because the server’s certificate is not yet valid.

      Available in iOS 3.0 and later.

    • CFURLErrorClientCertificateRejected

      kCFURLErrorClientCertificateRejected

      The secure connection failed because the client’s certificate was rejected.

      Available in iOS 3.0 and later.

    • CFURLErrorClientCertificateRequired

      kCFURLErrorClientCertificateRequired

      The secure connection failed because the server requires a client certificate.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotLoadFromNetwork

      kCFURLErrorCannotLoadFromNetwork

      The connection failed because it is being required to return a cached resource, but one is not available.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotCreateFile

      kCFURLErrorCannotCreateFile

      The file cannot be created.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotOpenFile

      kCFURLErrorCannotOpenFile

      The file cannot be opened.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotCloseFile

      kCFURLErrorCannotCloseFile

      The file cannot be closed.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotWriteToFile

      kCFURLErrorCannotWriteToFile

      The file cannot be written.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotRemoveFile

      kCFURLErrorCannotRemoveFile

      The file cannot be removed.

      Available in iOS 3.0 and later.

    • CFURLErrorCannotMoveFile

      kCFURLErrorCannotMoveFile

      The file cannot be moved.

      Available in iOS 3.0 and later.

    • CFURLErrorDownloadDecodingFailedMidStream

      kCFURLErrorDownloadDecodingFailedMidStream

      The download failed because decoding of the downloaded data failed mid-stream.

      Available in iOS 3.0 and later.

    • CFURLErrorDownloadDecodingFailedToComplete

      kCFURLErrorDownloadDecodingFailedToComplete

      The download failed because decoding of the downloaded data failed to complete.

      Available in iOS 3.0 and later.

    • CFHTTPCookieCannotParseCookieFile

      kCFHTTPCookieCannotParseCookieFile

      The cookie file cannot be parsed.

      Available in iOS 3.0 and later.

    • CFNetServiceErrorUnknown

      kCFNetServiceErrorUnknown

      An unknown error occurred.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorCollision

      kCFNetServiceErrorCollision

      An attempt was made to use a name that is already in use.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorNotFound

      kCFNetServiceErrorNotFound

      Not used.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorInProgress

      kCFNetServiceErrorInProgress

      A new search could not be started because a search is already in progress.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorBadArgument

      kCFNetServiceErrorBadArgument

      A required argument was not provided or was not valid.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorCancel

      kCFNetServiceErrorCancel

      The search or service was cancelled.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorInvalid

      kCFNetServiceErrorInvalid

      Invalid data was passed to a CFNetServices function.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorTimeout

      kCFNetServiceErrorTimeout

      A search failed because it timed out.

      Available in iOS 2.0 and later.

    • CFNetServiceErrorDNSServiceFailure

      kCFNetServiceErrorDNSServiceFailure

      DNS service discovery returned an error. You can query the kCFDNSServiceFailureKey key to find out the error returned by DNS service discovery and look up the code in /usr/include/dns_sd.h or DNS Service Discovery C Reference.

      Available in iOS 2.0 and later.

    Discussion

    To determine the source of an error, examine the userInfo dictionary included in the CFError object returned by a function call or call CFErrorGetDomain and pass in the CFError object and the domain whose value you want to read. These errors are all part of the kCFErrorDomainCFNetwork domain.

    Import Statement

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    let kCFURLErrorFailingURLErrorKey: CFString! let kCFURLErrorFailingURLStringErrorKey: CFString! let kCFGetAddrInfoFailureKey: CFString! let kCFSOCKSStatusCodeKey: CFString! let kCFSOCKSVersionKey: CFString! let kCFSOCKSNegotiationMethodKey: CFString! let kCFDNSServiceFailureKey: CFString! let kCFFTPStatusCodeKey: CFString!

    Objective-C

    extern const CFStringRef kCFURLErrorFailingURLErrorKey; extern const CFStringRef kCFURLErrorFailingURLStringErrorKey; extern const CFStringRef kCFGetAddrInfoFailureKey; extern const CFStringRef kCFSOCKSStatusCodeKey; extern const CFStringRef kCFSOCKSVersionKey; extern const CFStringRef kCFSOCKSNegotiationMethodKey; extern const CFStringRef kCFDNSServiceFailureKey; extern const CFStringRef kCFFTPStatusCodeKey;

    Constants

    • kCFURLErrorFailingURLErrorKey

      kCFURLErrorFailingURLErrorKey

      The URL that caused the load to fail as a CFURLRef object.

      Available in iOS 2.2 and later.

    • kCFURLErrorFailingURLStringErrorKey

      kCFURLErrorFailingURLStringErrorKey

      The URL that caused the load to fail as a CFStringRef object.

      Available in iOS 2.2 and later.

    • kCFGetAddrInfoFailureKey

      kCFGetAddrInfoFailureKey

      If an error of type kCFHostErrorUnknown is returned, this key returns the last error code returned by getaddrinfo in response to a DNS lookup. To interpret the results, look up the error code in /usr/include/netdb.h.

      Available in iOS 2.0 and later.

    • kCFSOCKSStatusCodeKey

      kCFSOCKSStatusCodeKey

      When a SOCKS error occurs, querying this key returns the last status code sent by the SOCKS server in response to the previous operation.

      Available in iOS 2.0 and later.

    • kCFSOCKSVersionKey

      kCFSOCKSVersionKey

      If an error of type kCFSOCKSErrorUnsupportedServerVersion is returned, querying this key returns the SOCKS version in use by the current connection.

      Available in iOS 2.0 and later.

    • kCFSOCKSNegotiationMethodKey

      kCFSOCKSNegotiationMethodKey

      If an error of type kCFSOCKS5ErrorUnsupportedNegotiationMethod is returned, querying this key returns the negotiation method requested by the SOCKS server.

      Available in iOS 2.0 and later.

    • kCFDNSServiceFailureKey

      kCFDNSServiceFailureKey

      If an error of type kCFNetServicesErrorDNSServiceFailure is returned, querying this key returns the last error returned by the DNS resolver libraries in response to the previous operation. To interpret the results, look up the error codes in /usr/include/dns_sd.h or DNS Service Discovery C Reference.

      Available in iOS 2.0 and later.

    • kCFFTPStatusCodeKey

      kCFFTPStatusCodeKey

      If an error of type kCFFTPErrorUnexpectedStatusCode is returned, querying this key returns the last status code sent by the FTP server in response to the previous operation.

      Available in iOS 2.0 and later.

    Discussion

    Many network functions return CFErrorRef objects. When the error object's domain is kCFErrorDomainCFNetwork, you can query the object for additional information.

    For example:

    • if (CFEqual(CFErrorGetDomain(err), kCFErrorDomainCFNetwork) && CFErrorGetCode(err) == kCFHostErrorUnknown) {
    • CFDictionaryRef userInfo = CFErrorCopyUserInfo(err);
    • CFNumberRef number = (CFNumberRef) CFDictionaryGetValue(userInfo, kCFGetAddrInfoFailureKey);
    • ...
    • CFRelease(userInfo);
    • }

    Import Statement

  • High-level error domains.

    Declaration

    Swift

    let kCFErrorDomainCFNetwork: CFString! let kCFErrorDomainWinSock: CFString!

    Objective-C

    extern const CFStringRef kCFErrorDomainCFNetwork; extern const CFStringRef kCFErrorDomainWinSock;

    Constants

    • kCFErrorDomainCFNetwork

      kCFErrorDomainCFNetwork

      Error domain that returns error codes specific to the CFNetwork stack.

      Available in iOS 2.0 and later.

    • kCFErrorDomainWinSock

      kCFErrorDomainWinSock

      Error domain that returns error codes specific to the underlying network layer when running CFNetwork code on Windows.

      Available in iOS 2.0 and later.

    Discussion

    To determine the source of an error, examine the userInfo dictionary included in the CFError object returned by a function call or call CFErrorGetDomain and pass in the CFError object and the domain whose value you want to read.

    Import Statement