iOS Developer Library

Developer

CoreServices Framework Reference CFNetDiagnostics Reference

Options
Deployment Target:

On This Page
Language:

CFNetDiagnostics Reference

The CFNetDiagnostics opaque type allows you to diagnose network-related problems.

Functions

  • Creates a network diagnostic object from a pair of CFStreams.

    Declaration

    Swift

    func CFNetDiagnosticCreateWithStreams(_ alloc: CFAllocator!, _ readStream: CFReadStream!, _ writeStream: CFWriteStream!) -> Unmanaged<CFNetDiagnostic>!

    Objective-C

    CFNetDiagnosticRef CFNetDiagnosticCreateWithStreams ( CFAllocatorRef alloc, CFReadStreamRef readStream, CFWriteStreamRef writeStream );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    readStream

    Reference to a read stream whose connection has failed, or NULL if you do not want the CFNetDiagnosticRef to have a read stream.

    writeStream

    Reference to a write stream whose connection has failed, or NULL if you do not want the CFNetDiagnosticRef to have a write stream.

    function result

    CFNetDiagnosticRef that you can pass to CFNetDiagnosticDiagnoseProblemInteractively or CFNetDiagnosticCopyNetworkStatusPassively. Ownership follows the Create Rule.

    Discussion

    This function uses references to a read steam and a write stream (or just a read stream or just a write stream) to create a reference to an instance of a CFNetDiagnostic object. You can pass the reference to CFNetDiagnosticDiagnoseProblemInteractively to open a Network Diagnostics window or to CFNetDiagnosticCopyNetworkStatusPassively to get a description of the connection referenced by readStream and writeStream.

    Special Considerations

    This function is thread safe as long as another thread does not alter the same CFNetDiagnosticRef at the same time.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Creates a CFNetDiagnosticRef from a CFURLRef.

    Declaration

    Swift

    func CFNetDiagnosticCreateWithURL(_ alloc: CFAllocator!, _ url: CFURL!) -> Unmanaged<CFNetDiagnostic>!

    Objective-C

    CFNetDiagnosticRef CFNetDiagnosticCreateWithURL ( CFAllocatorRef alloc, CFURLRef url );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    url

    CFURLRef that refers to the failed connection.

    Return Value

    CFNetDiagnosticRef that you can pass to CFNetDiagnosticDiagnoseProblemInteractively or CFNetDiagnosticCopyNetworkStatusPassively. Ownership follows the Create Rule.

    Discussion

    This function uses a URL to create a reference to an instance of a CFNetDiagnostic object. You can pass the reference to CFNetDiagnosticDiagnoseProblemInteractively to open a Network Diagnostics window or to CFNetDiagnosticCopyNetworkStatusPassively to get a description of the connection referenced by readStream and writeStream.

    Special Considerations

    This function is thread safe as long as another thread does not alter the same CFNetDiagnosticRef at the same time.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Overrides the displayed application name.

    Declaration

    Swift

    func CFNetDiagnosticSetName(_ details: CFNetDiagnostic!, _ name: CFString!)

    Objective-C

    void CFNetDiagnosticSetName ( CFNetDiagnosticRef details, CFStringRef name );

    Parameters

    details

    The network diagnostics object for which the application name is to be set.

    name

    Name that is to be set.

    Discussion

    Frameworks requiring that an application name be displayed to the user derive the application name from the bundle identifier of the currently running application, in that application’s localization. If you want to override the derived application name, use this function to set the name that is displayed.

    Special Considerations

    This function is thread safe as long as another thread does not alter the same CFNetDiagnosticRef at the same time.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Opens a Network Diagnostics window.

    Declaration

    Swift

    func CFNetDiagnosticDiagnoseProblemInteractively(_ details: CFNetDiagnostic!) -> CFNetDiagnosticStatus

    Objective-C

    CFNetDiagnosticStatus CFNetDiagnosticDiagnoseProblemInteractively ( CFNetDiagnosticRef details );

    Parameters

    details

    A network diagnostics object, created by CFNetDiagnosticCreateWithStreams or CFNetDiagnosticCreateWithURL, for which the window is to be opened.

    Return Value

    CFNetDiagnosticNoErr if no error occurred, or CFNetDiagnosticErr if an error occurred that prevented this call from completing successfully.

    Discussion

    This function opens the Network Diagnostics window and returns immediately once the window is open.

    Special Considerations

    This function is thread safe as long as another thread does not alter the same CFNetDiagnosticRef at the same time.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Gets a network status value.

    Declaration

    Swift

    func CFNetDiagnosticCopyNetworkStatusPassively(_ details: CFNetDiagnostic!, _ description: UnsafeMutablePointer<Unmanaged<CFString>?>) -> CFNetDiagnosticStatus

    Objective-C

    CFNetDiagnosticStatus CFNetDiagnosticCopyNetworkStatusPassively ( CFNetDiagnosticRef details, CFStringRef *description );

    Parameters

    details

    CFNetDiagnosticRef, created by CFNetDiagnosticCreateWithStreams or CFNetDiagnosticCreateWithURL, for which the Network Diagnostics status is to be obtained.

    description

    If not NULL, upon return contains a localized string containing a description of the current network status. Ownership follows the Create Rule.

    Return Value

    A network status value.

    Discussion

    This function returns a status value that can be used to display basic information about the connection, and optionally gets a localized string containing a description of the current network status.

    This function is guaranteed not to generate network activity.

    Special Considerations

    This function is thread safe as long as another thread does not alter the same CFNetDiagnosticRef at the same time.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

Data Types

  • An opaque reference representing a CFNetDiagnostic.

    Declaration

    Swift

    typealias CFNetDiagnosticRef = CFNetDiagnostic

    Objective-C

    typedef struct __CFNetDiagnostic* CFNetDiagnosticRef;

    Availability

    Available in iOS 2.0 and later.

  • A CFIndex type that is used to return status values from CFNetDiagnostic status and diagnostic functions. For a list of possible values, see CFNetDiagnosticStatusValues Constants.

    Declaration

    Swift

    typealias CFNetDiagnosticStatus = CFIndex

    Objective-C

    typedef CFIndex CFNetDiagnosticStatus;

    Availability

    Available in iOS 2.0 and later.

Constants

  • Constants for diagnostic status values.

    Declaration

    Swift

    enum CFNetDiagnosticStatusValues : Int32 { case NoErr case Err case ConnectionUp case ConnectionIndeterminate case ConnectionDown }

    Objective-C

    enum CFNetDiagnosticStatusValues { kCFNetDiagnosticNoErr = 0, kCFNetDiagnosticErr = -66560L, kCFNetDiagnosticConnectionUp = -66559L, kCFNetDiagnosticConnectionIndeterminate = -66558L, kCFNetDiagnosticConnectionDown = -66557L }; typedef enum CFNetDiagnosticStatusValues CFNetDiagnosticStatusValues;

    Constants

    • NoErr

      kCFNetDiagnosticNoErr

      No error occurred but there is no status.

      Available in iOS 2.0 and later.

    • Err

      kCFNetDiagnosticErr

      An error occurred that prevented the call from completing.

      Available in iOS 2.0 and later.

    • ConnectionUp

      kCFNetDiagnosticConnectionUp

      The connection appears to be working.

      Available in iOS 2.0 and later.

    • ConnectionIndeterminate

      kCFNetDiagnosticConnectionIndeterminate

      The status of the connection is not known.

      Available in iOS 2.0 and later.

    • ConnectionDown

      kCFNetDiagnosticConnectionDown

      The connection does not appear to be working.

      Available in iOS 2.0 and later.

    Discussion

    Diagnostic status values are returned by CFNetDiagnosticDiagnoseProblemInteractively and CFNetDiagnosticCopyNetworkStatusPassively.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.