It seems like there a bunch of ways to do networking in Cocoa: Webkit, NSUrl, CFNetwork, BSD Sockets. Is there any other APIs/Frameworks that are commonly used for networking? I’m trying to understand all the ways to do networking in Cocoa and learn each one’s strength’s and weaknesses.
As a related question, why would anyone use CFSocket? It seems that most things can be done with NSUrl or BSD Sockets. Is CFSocket commonly used in practice?
You can watch the WWDC videos Network Apps for iPhone (Part 1, Part 2) and Networking Best Practices where they suggest to use NSURLConnection for HTTP and HTTPS, the CFSocket/CFStream/NSStream family for other TCP networking, and of course WebKit if you just intend to render web content. They advice against using the low-level BSD sockets, unless you’re writing a server. The higher level frameworks you use, the more things are taken care for you (from DNS resolution to cellular network management, authentication, encryption, run loop integration…) and the more it is integrated to the rest of the Cocoa framework.