Use SOCKET for C/S structure programming and connection process
The server listens to a port for connection requests. ServerProgramThe client is in a blocked state and can only run down until it sends a connection request to the server. Once the connection is established, the input and output stream objects can be obtained through socket. You can use the input/output stream object to communicate with the client. Do not forget to close the socket and release some resources (including closing the input/output stream ).
The client process is to first specify the Server IP address and port to communicate with and the transmission protocol (TCP or UDP) used to send a connection request to the server. After the server responds to the request, a connection will be established. Then it is the same as the server.
In iOS, client socket programming can use three technologies:
1. Use nsstream. Objective-C language-oriented implementation of Apis provided by Apple's foundation framework;
2. Use cfstream. C language-oriented implementation, provided by the core foundation framework provided by Apple;
BSD socket. Berkeley socket is a widely used socket programming on UNIX platforms. It is implemented in C language and fully written in C, which is troublesome to use. It was developed by students at the University of California (Berkeley.
In iOS, server-side socket programming can use two technologies:
1. Use cfstream. C language-oriented implementation, provided by the core foundation framework provided by Apple;
2 BSD socket. Berkeley socket is a widely used socket programming on UNIX platforms. It is implemented in C language and fully written in C, which is troublesome to use. It was developed by students at the University of California (Berkeley.
IOS network programming and cloud application best practices http://www.iosbook3.com