Using Network Diagnostics (using the Web diagnostics)

Source: Internet
Author: User

In many network-based applications, network-based errors occur that are not related to your application. However, most users may not know why the app failed. The Cfnetdiagnostics API gives you a quick and easy way to help users solve network problems.

If your app uses a Cfstream object, then call the cfnetdiagnosticcreatewithstreams function to create a network diagnostic reference (cfnetdiagnosticref). The Cfnetdiagnosticcreatewithstreams has an allocator that reads the stream and writes the stream as a parameter. If your app uses only read or write streams, the unused parameters are set to NULL.

If no stream exists, you can also create a network diagnostic reference directly from the URL. To do this, call the cfnetdiagnosticcreatewithurl function and pass an allocator, URL to cfurlref. It will return a network diagnostic reference for you to use.

In order to diagnose the problem through the Network diagnostic assistant, call the cfnetdiagnosticdiagnoseprobleminteractively function and pass the network diagnostic reference. Listing 6-1 shows how to use Cfnetdiagnostics to diagnose a stream implemented on a running loop.

Checklist 6-1 using the Cfnetdiagnostics API when a stream error occurs

Case kcfstreameventerroroccurred:        cfnetdiagnosticref diagref =            cfnetdiagnosticcreatewithstreams (NULL, Stream, NULL);        (void) Cfnetdiagnosticdiagnoseprobleminteractively (diagref);        Cfstreamerror error = Cfreadstreamgeterror (stream);        ReportError (error);        Cfreadstreamclose (stream);        Cfrelease (stream);        Break


Cfnetworkdiagnostics can also retrieve the status of the problem, rather than using the network diagnostic assistant. You can do this by calling cfnetdiagnosticcopynetworkstatuspassively. The function returns a constant such as kcfnetdiagnosticconnectionup or kcfnetdiagnosticconnectionindeterminate.


Official Original address:

https://developer.apple.com/library/ios/documentation/Networking/Conceptual/CFNetwork/UsingNetworkDiagnostics/ Usingnetworkdiagnostics.html#//apple_ref/doc/uid/tp30001132-ch7-sw1

Using Network Diagnostics (using the Web diagnostics)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.