On iOS, there is a library called core Foundation networking or cfnetwork, which is a lightweight package for the original socket, but it quickly becomes cumbersome for most common scenarios. Finally, another layer (nsstream) is added to encapsulate the cfnetwork and act as the most basic OBJECTIVE-C network API. Classes that are more familiar to you (such as nsurlconnection and UIWebView) are very easy to use and can do a lot of things with very little code, thanks to the solid foundation that these underlying libraries provide.
One, BSD Socket
Apple does not recommend this approach because the original socket does not have access to the operating system's built-in network features, such as a system-wide VPN. Even worse, initializing the socket connection does not automatically turn on the device's Wi-Fi or cellular radio. The radio will turn off intelligently to conserve battery power, and any communication connection will fail unless the radio is activated by other network routines. Cfnetwork the BSD socket package activates the device's radio, so in almost all scenarios, we recommend the use of Cfnetwrok, not the BSD socket.
Two, cfnetwork
The CFNETWORKD is located in the upper layer of the frame hierarchy and is a lightweight package for BSD sockets.
Three, Nsstream
The goose bumps along the frame level are nsstream, which is the Objective-c wrapper for the Cfnetwork API.
Four, summarize.
As the frame level goes up, the code is shorter and simpler, but you lose some power because each abstraction layer hides the original network socket that actually performs the communication.
Reference: "iOS network advanced programming-iphone and ipad Enterprise application Development"
"Reading notes" iOS network-Underlying network