5.29-032- Wednesday

What we learn today

    A half the number of connections

    Second, stick package problem

    Third, to solve the problem

    Fourth, the custom header

A half the number of connections

Called three-way handshake is not completed semijoin

the reason:

  1) The client does not return the malicious third handshake

  2) server did not empty the timely processing of your request

In the socket, socket.listen (half the maximum number of connections)

 

Second, stick package problem

 

Why is there a problem stick package:

  Due to the use of TCP streaming protocol, there is no demarcation between the data, just like water, pour a glass of water and a glass of milk together!

  Transmitting data using UDP User Datagram Protocol

Stick package occurs only in the TCP protocol

  1) a small amount of data sent by a transmitter and spaced a short stick

  2) the receiving terminal reads the contents of the disposable stick two data

  3) the receiver is not receiving a complete and the next stick remaining contents are transmitted together with the next received packet to become sticky

In either case, the fundamental reason is: the receiver does not know how much data in the end, I do not know two or more times the data sent from the boundary where

Third, the solution

  Starting (advance notice) length of the data to a recipient, and then transmits the real data, the data received by the receiver before the data length of the received

The sender

  1) length of the real data to the struct data bytes into fixed

  2) the length of the data transmission

  3) send real data

Receiving end

  Number 1) the length of the first data byte of received data fixed

  2) then received real real may require a long reception cycle

During execution, the sender and receiver must be treated stick package truly solved

 

Fourth, the custom header

When required some additional paging parameters during data transmission requires a custom header , header data is essentially a json

Specific process is as follows:

  The sender

    1) transmission header length

    2) the data transmission header which contains the file length and any other additional information

    3) Send the file contents

  Receiving end

    1) receives the header length

    2) receives the header information

    3) receive the file contents

 

Guess you like

Origin www.cnblogs.com/Chinesehan/p/10945078.html