iOS Networking CS328 Big Picture Core Foundation Networking • CF Networking APIs are abstractions on top of the BSD sockets to make it easier to program network protocols. – – – – – – working with BSD sockets Creating and using SSL and TLS Resolving DNS host requests Working with HTTP Working with FTP Publishing , resolving and browsing Bonjour services CF Network Concepts • Low level, high performance framework to give detailed control over the protocol stack • An extension of BSD sockets CFSocket and CFStream • CFSocket and CFStream are fundamental to CFNetwork • First we’ll look at both before looking at CFNetwork CFSocket • Most basic level of network communication • Uses BSD Socket but the abstraction allows the CFSocket to be integrated with a program run-loop. • Can also be used for UDP sockets. CFSocket • CFSocketCreate – makes a CFSocket from scratch • CFSocketCreateWithNative – Create a CFSocket out of a BSD socket • CFSocketCreateRunLoopSource – Create a CFSocket to use in a program run loop. • CFSocket Reference CFStream • Provides the abstraction to read and write information from one socket on the local machine and another on a remote machine (could also be on the local machine). • Streams can be attached to memory, files or sockets/network • CFReadStream • CFWriteStream The Framework Using • • • • • • Use in the same way as a UNIX stream Create the stream (instantiate it) Open it Read or write it. Close/Dispose of CFStream Reference Other CFNetwork APIs • CFFTP – create read/write streams for uploading and downloading files from FTP servers. This implements the FTP protocol • CFHTTP - create read/write streams for sending HTTP Requests and receiving HTTP Response packets. This implements the HTTP protocol • CFHTTPAuthentication – provides for interfacing with an HTTP server set up for challenge/response authentication. • CFHost – Lets you query host information from DNS. • CFNetServices – Interface to Bonjour. Bonjour • Bonjour is Apple Inc.'s trade name for its implementation of Zeroconf, a group of technologies that includes service discovery, address assignment, and name resolution. Bonjour locates devices such as printers, other computers, and the services that those devices offer on a local network using multicast Domain Name System (mDNS) service records. Zeroconf • Zero configuration networking (zeroconf), is a set of techniques that automatically creates a usable Internet Protocol (IP) network without manual operator intervention or special configuration servers.