- iOS and OS X Network Programming Cookbook
- Jon Hoffman
- 369字
- 2021-07-19 18:40:40
Introduction
The primary API behind Apple's low-level networking is the CFNetwork API.
The simplest way to describe CFNetworking is to say that it is an Apple-specific extension to the BSD socket API. The CFNetworking stack is based on and relies on the BSD socket API that was discussed in Chapter 1, BSD Socket Library. It is recommended that the reader understands the concepts discussed in Chapter 1, BSD Socket Library, prior to going through this chapter. While this chapter will focus primarily on CFNetworking for most of the recipes, we will also use NSHost
and the system configuration framework for retrieving network address information and checking the network status recipes. The biggest advantage that BSD sockets have over CFNetwork is the compatibility with other forms of Unix. This is a pretty big advantage when you think of all the BSD socket code on the Internet that you can use. However, if your application is Apple-specific, it is recommended that you use CFNetwork wherever you can.
CFNetwork offers numerous advantages over BSD sockets. The biggest advantage is the run-loop integration. So if your application is run-loop-based, you will be able to implement network services without implementing numerous threads.
CFNetwork also contains a number of objects to help you implement specific protocols without having to know the implementation details about the protocols. This includes the CFFTP API to assist in implementing the FTP protocol, and CFHTTP to assist in implementing the HTTP protocol.
To understand CFNetworking, you should be aware of the main building blocks that make up CFNetwork, which are as follows:
- CFSocket: It is an abstraction of the BSD socket covered in Chapter 1, BSD Socket Library. One of the main differences between the BSD socket and the CFSocket is that the CFSocket can be integrated with a run loop.
- CFStream: It provides both read and write streams and makes it easy to exchange data not only across networks but also with files and memory objects.
- CFSocketStream: It provides an extension for CFStream to work with network sockets.
- CFFTP: It provides an API for communicating with FTP servers.
- CFHTTP: It provides an API for communicating with HTTP servers.
- CFHTTPAuthentication: It provides an API for responding to HTTP authentication challenges.
- 漫話大數據
- 數據可視化:從小白到數據工程師的成長之路
- Visual Studio 2015 Cookbook(Second Edition)
- 文本數據挖掘:基于R語言
- R數據科學實戰:工具詳解與案例分析(鮮讀版)
- 數據結構與算法(C語言版)
- 數據架構與商業智能
- 軟件成本度量國家標準實施指南:理論、方法與實踐
- MySQL 8.x從入門到精通(視頻教學版)
- 從0到1:JavaScript 快速上手
- 淘寶、天貓電商數據分析與挖掘實戰(第2版)
- 數據科學實戰指南
- Power BI智能數據分析與可視化從入門到精通
- Mastering LOB Development for Silverlight 5:A Case Study in Action
- 數據庫應用系統技術