CFNetwork編程指南介紹
@官方文檔翻譯-李冰
@譯文
CFNetwork提供了網(wǎng)絡(luò)協(xié)議抽象庫的最為核心的服務(wù)框架。這些抽象使得它更容易執(zhí)行各種網(wǎng)絡(luò)任務(wù),比如:
- 與BSD套接字的工作
- 用SSL或者TLS建立加密連接
- 解析DNS主機(jī)
- 使用HTTP協(xié)議,HTTP和HTTP協(xié)議的服務(wù)器認(rèn)證
- 使用FTP服務(wù)器
- 發(fā)行,解決和瀏覽Bonjour服務(wù)(在NSNetServices和CFNetServices編程指南中描述)
這本書為想要在自己的應(yīng)用程序中使用網(wǎng)絡(luò)協(xié)議的開發(fā)者準(zhǔn)備的。為了更全面的了解這本書,讀者需要對網(wǎng)絡(luò)編程概念有一個(gè)很好的理解比如BSD套接字,流和HTTP協(xié)議。此外,讀者需要熟悉OS X編程概念包括run loops。更多關(guān)于OS X的信息請閱讀Mac Technology Overview。
文檔結(jié)構(gòu)
這本書包括以下章節(jié):
- CFNetwork ConceptsCFNetwork(一) 描述CFNetwork的每個(gè)API以及它們?nèi)绾蜗嗷プ饔谩?/li>
- Working with Streams-CFNetwork(二) 怎樣使用CFStream的API取發(fā)送和接收網(wǎng)絡(luò)數(shù)據(jù)。
- Communicating with HTTP Servers-CFNetwork(三) 描述怎樣發(fā)送和接收HTTP消息。
- Communicating with Authenticating HTTP ServersCFNetwork(四) 描述怎樣與安全的HTTP服務(wù)器通信。
- Working with FTP ServersCFNetwork(五) 描述怎樣從FTP服務(wù)器去上傳和下載文件,以及怎樣去下載文件列表。
- Using Network DiagnosticsCFNetwork(六) 描述怎樣去添加網(wǎng)絡(luò)診斷到你的應(yīng)用程序。
參見
更多的關(guān)于OS X的網(wǎng)絡(luò)APIs,可閱讀:
- Getting Started With Networking
CFNetwork參閱下面的參考文檔:
CFFTPStream Reference 是CFFTPStream的API參考文檔
CFHTTPMessage Reference 是CFHTTPMessage的API參考文檔
CFHTTPStream Reference 是CFHTTPStream的API參考文檔
CFHTTPAuthentication Reference 是CFHTTPAuthentication 的API參考文檔
CFHost Reference 是CFHost的API參考文檔
CFNetService Reference 是CFNetServices的API參考文檔
CFNetDiagnostics Reference 是CFNetDiagnostics的API參考文檔
除了蘋果提供的文檔外,下面是socket級別編程的參考書:
- UNIX Network Programming, Volume 1 (Stevens, Fenner and Rudoff)
CFNetwork is a framework in the Core Services framework that provides a library of abstractions for network protocols. These abstractions make it easy to perform a variety of network tasks, such as:
- Working with BSD sockets
- Creating encrypted connections using SSL or TLS
- Resolving DNS hosts
- Working with HTTP, authenticating HTTP and HTTPS servers
- Working with FTP servers
- Publishing, resolving and browsing Bonjour services (described in NSNetServices and CFNetServices Programming Guide)
This book is intended for developers who want to use network protocols in their applications. In order to fully understand this book, the reader should have a good understanding of network programming concepts such as BSD sockets, streams and HTTP protocols. Additionally, the reader should be familiar OS X programming concepts including run loops. For more information about OS X please read Mac Technology Overview.
Organization of This Document
This book contains the following chapters:
- CFNetwork Concepts describes each of the CFNetwork APIs and how they interact.
- Working with Streams describes how to use the CFStream API to send and receive network data.
- Communicating with HTTP Servers describes how to send and receive HTTP messages.
- Communicating with Authenticating HTTP Servers describes how to communicate with secure HTTP servers.
- Working with FTP Servers describes how to upload and download files from an FTP server, and how to download directory listings.
- Using Network Diagnostics describes how to add network diagnostics to your application.
See Also
For more information about the networking APIs in OS X, read:
- Getting Started With Networking
Refer to the following reference documents for CFNetwork:
- CFFTPStream Reference is the reference documentation for the CFFTPStream API.
- CFHTTPMessage Reference is the reference documentation for the CFHTTPMessage API.
- CFHTTPStream Reference is the reference documentation for the CFHTTPStream API.
- CFHTTPAuthentication Reference is the reference documentation for the CFHTTPAuthentication API.
- CFHost Reference is the reference documentation for the CFHost API.
- CFNetService Reference is the reference documentation for the CFNetServices API.
- CFNetDiagnostics Reference is the reference documentation for the CFNetDiagnostics API.
In addition to the documentation provided by Apple, the following is the reference book for socket-level programming:
- UNIX Network Programming, Volume 1 (Stevens, Fenner and Rudoff)