The application layer on the network communication simple understanding socket

1.socket can be considered as we usually use the telephone exchange, a communication tool

2. The communication protocol is the language we use to communicate. There are two generally mainstream communication protocols: TCP and UDP. Will conduct three-way handshake TCP communication, the transmission data is secure but low speed. UDP does not directly send the handshake, the data speed can not be maintained, but

Cards, we usually see online video is UDP, fast transmission, occasional video frequency jitter or spend very short but does not affect our watch.

3.socket communication requires server-side and client-side, server-side to create a socket, put their IP and port and protocol set up, the best port after 50,000, this does not affect other processes, not conflict, the client Chong himself

Build a socket, then connect to the server, the server receives a client request immediately and then create a specialized client communication and the socket, so that communication is successful.

4. If a plurality of clients are connected, it is necessary to distinguish between the transmission data client, here a key table key method can quickly find the value to match the transmission.

5. Send message, when such different data files, need to add code to distinguish the first, i.e. before the cache needs to send code then plug into the head, an array of troublesome operation, may be used herein to get set,

  On the set of functions, all functions of the array can be achieved, the set can be achieved, on the contrary, a collection of some of the features that can be realized, the array is difficult to achieve. A set of variable length: the number of stored data, during the execution of the program may be in continuous change occurs (memory for multiple traverses slow).

  List collection: Create: definition, assignment, the initializer List <int> nums = new List <int> (); nums no element length defaults to 0, then may be changed, can add or delete elements.

  Adding elements: the end of the collection, adding a new element variable name .Add (to add data).

  Insert elements: the collection to the specified location, insert a new element variable names .Instert (index data to be inserted).

  Removing elements: variable name .RemoveAT (index); remove elements variable name .Remove (data) specified index; deleted data collection and fill the same first match.

  Modify elements: a modified value of the variable name of an element in the set [index] = value; exactly read and modify the operation of the array elements.

  Gets the number of elements: variable name Gets a collection of .lount

  Variable name = new List <Data Type> (); after the assignment may vary in length        combined Writing: List <Data Type> variable name = new List <Data Type> ();

  Initializer: variable name = new List <Data Type> {element 1, element 2, ......., element n};

Guess you like

Origin www.cnblogs.com/pacexdong/p/11442349.html