CodePudding user response:
According to the length of frame head + + data + check + tail frame way to make a transfer protocol, send and receive are in accordance with the agreement is very easy to doCodePudding user response:
Certainly there are other problems, or you want to send, will recvTCP protocol, which can guarantee that you received the order of the data and send you the order of the same (not considering packet loss),
But does not guarantee that every recv can receive to complete a packet, there is no guarantee that every recv only receives a packet,
In the process of actual sent, will be sent to you the package split or merge,
So you must use an application layer protocol to read data, can be used for general agreement, also can be customized,
By the way, if the development of large projects later, also have to consider some trouble, send the abnormal data,
CodePudding user response:
It need upper make an agreement, you tell the size of the data, then according to the size to receive follow-up data ~CodePudding user response:
Send the return value will tell you (send) the size of the actual entry agreement, both the communication buffer, such as from A to BA. send buffer hypothesis 2
B have receive buffer, assumption of 4
10 in using the send to send A, if B is not recv, generally is
Send back to 6, there are four buffer has been sent to B, there are two in local buffer
CodePudding user response:
This is common sense, the basis of TCP/IP advice first look at the basic concepts, bit by bit! TCP/IP, rounding