IOS reading notes-Web API

Source: Internet
Author: User

The article from "iOS Network advanced Programming" Here is just excerpts, there are a lot of things do not know what is, and so finish the whole book of notes back to look.

Each layer of the framework provides a set of key APIs that provide a variety of functions and controls for developers.
1 Nsurlconnection is a cocoa-level API that provides an easy way to load URL requests, interact directly with Web service, get pictures, video, and simply get a formatted HTML document. It is built on top of the Nsstream and is optimized for HTTP, HTTPS, files, and FTP. Nsurlconnection restricts the protocols you use, but provides a robust caching engine.
2 Game Kit
The core function of the game kit is to provide a point-and-dot networking option. In a traditional network configuration, the game kit is built on top of the Bonjour, however, the game kit does not require a network infrastructure to be used. He can create a self-set Bluetooth personal area networks (PAN), which is a good network candidate where there is little or no base network.
3 Bonjour
Bonjour is Apple's implementation of the 0 configuration network. It provides a mechanism to detect and connect to network devices without needing to know the network address of the device. Bonjour refers to a service by name, service type, and domain component. He abstracted the underlying network required for multicast DNS and DNS-based service exploration.
At the cocoa layer, the Nsnetservice API provides an interface for publishing and parsing address information for Bonjour services, which can be explored through the Nsnetservicebrowser API for available services on the network. Publishing the Bonjour service requires understanding the core Foundation to configure the sockets required for communication.
4 Nsstream
Nsstream is a cocoa level API, built on top of Cfnetwork, the most Nsurlconnection Foundation, designed to accomplish some network tasks. Similar to Nsurlconnection,nsstream provides a mechanism for communicating with a remote server or local file. However, you can communicate through Nsstream on protocols such as Telnet or SMTP that are not supported by Nsurlconnection.
The additional control provided by the Nsstream is at a cost. He does not provide support for HTTP/S response status codes or authentication built-in. The data that he sends and receives is in the buffer of C. He is still unable to manage multiple outgoing requests, and subclasses are required to add this feature. Nsstream is asynchronous, and communication updates are implemented through Nsstreamdelegate.
5CFNetwork
The Cfnetwork API is located on the base BSD socket and is used in the implementation of the Nsstream, url loading system, Bonjour and Geme Kit API, which provides native support for advanced protocols such as HTTP and FTP. The main difference between Cfnetwork and BSD sockets is the integration of running loops. If the application uses cfnetwork then both the input and output are dispatched in the run loop.
Cfnetwork provides more configuration options than the URL-loading system. You can use these configuration options when creating HTTP requests using Cfnetwork, and you need to manually add the HTTP headers and cookie information that the request sends together when you create the request. In Nsurlconnection, these will be added automatically.
The Cfnetwork infrastructure is built on the core Foundation layer's cfsocket and Cfstream APIs, Cfnetwork contains APIs for specific protocols, such as CFFTP for FTP server communication, Cfhttp for sending and receiving HTTP messages, cfnetservices for publishing and browsing the Bonjour service, and so on.
6 BSD Socket
Forms the basis for most Internet activities and is at the bottom of the network architecture. BSD sockets are implemented using C, but can be used in OC. BSD Socket API is not recommended, for example, BSD sockets cannot pass through the system-wide vpn,wi-fi or cellular radios are turned off, and their APIs cannot be activated automatically. Apple recommends using Cfnetwork or a higher-level API.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IOS reading notes-Web API

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.