CFNetwork編程指南介紹
@官方文檔翻譯-李冰
@譯文
CFNetwork提供了網絡協(xié)議抽象庫的最為核心的服務框架编饺。這些抽象使得它更容易執(zhí)行各種網絡任務,比如:
- 與BSD套接字的工作
- 用SSL或者TLS建立加密連接
- 解析DNS主機
- 使用HTTP協(xié)議响驴,HTTP和HTTP協(xié)議的服務器認證
- 使用FTP服務器
- 發(fā)行透且,解決和瀏覽Bonjour服務(在NSNetServices和CFNetServices編程指南中描述)
這本書為想要在自己的應用程序中使用網絡協(xié)議的開發(fā)者準備的。為了更全面的了解這本書,讀者需要對網絡編程概念有一個很好的理解比如BSD套接字秽誊,流和HTTP協(xié)議鲸沮。此外,讀者需要熟悉OS X編程概念包括run loops锅论。更多關于OS X的信息請閱讀Mac Technology Overview讼溺。
文檔結構
這本書包括以下章節(jié):
- CFNetwork ConceptsCFNetwork(一) 描述CFNetwork的每個API以及它們如何相互作用。
- Working with Streams-CFNetwork(二) 怎樣使用CFStream的API取發(fā)送和接收網絡數(shù)據(jù)最易。
- Communicating with HTTP Servers-CFNetwork(三) 描述怎樣發(fā)送和接收HTTP消息怒坯。
- Communicating with Authenticating HTTP ServersCFNetwork(四) 描述怎樣與安全的HTTP服務器通信。
- Working with FTP ServersCFNetwork(五) 描述怎樣從FTP服務器去上傳和下載文件藻懒,以及怎樣去下載文件列表剔猿。
- Using Network DiagnosticsCFNetwork(六) 描述怎樣去添加網絡診斷到你的應用程序。
參見
更多的關于OS X的網絡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)