Using socket for C/s structure programming, connection process
The server side listens for a connection request on a port. The server-side program is blocked until the client issues a connection request to the server, and the server-side accepts the requestor to run down. Once the connection is established, the input output stream object can be obtained through the socket. Communication with the client can be achieved by means of an input-output stream object, and the last thing to do is to close the socket and release some resources (including: Turn off the input/output stream).
The client process specifies the server IP address, port, and transport protocol (TCP or UDP) to be communicated, a connection request is made to the server, and a connection is established after the server has an answer request. And then the server side is the same.
In iOS, there are three techniques available for client socket programming:
1 Use Nsstream. For the implementation of OBJECTIVE-C language, the API provided by the Foundation framework provided by Apple;
2 Use Cfstream. For C-language implementation, the core Foundation framework provided by Apple provides the API;
BSD Socket. Also called the Berkeley socket (Berkeley socket), is widely used in UNIX platform socket programming. It is for C language implementation, full use of C writing, use more trouble. It was developed by students at the University of California, Berkeley (University of California, Berkeley).
In iOS, server-side socket programming can be used in two different technologies:
1 Use Cfstream. For C-language implementation, the core Foundation framework provided by Apple provides the API;
2 BSD Socket. Also called the Berkeley socket (Berkeley socket), is widely used in UNIX platform socket programming. It is for C language implementation, full use of C written, use up more trouble. It was developed by students at the University of California, Berkeley (University of California, Berkeley).
This article is from the "Dongsheng" blog, please be sure to keep this source http://2009315319.blog.51cto.com/701759/1176604