Home > other >  C # network transmission
C # network transmission

Time:10-06

If say I have a byte array size 1024
My cache size is 250

If every time send 200 data, send 5 times
Don't say the second sent there will be a little touch to the top of the first

If say I have a byte array size 1024 MB (particularly)
My cache size is 250 m (special)

If every time to send 200 m data, send 5 times
Will be sent when receiving the second is a little touch to the top of the first?

CodePudding user response:

Stick package cannot avoid completely, there are two kinds of treatment method of
One is S written in the WEB project, C end to the HTTP interface, this case can avoid glue bag, don't need you to handle, by the WEB server to completely;
Another is to define their own data structures, finally complete package, according to the data structure to parse the data,
Such as the two messages are split into three packages:
Figures 1 & lt; EN
D> Count
According to the 2 & lt; END>
Received the first to throw the cache together, and then parse,

CodePudding user response:

reference 1st floor Runnerchin response:
stick package cannot avoid completely, there are two kinds of treatment method of
One is S written in the WEB project, C end to the HTTP interface, this case can avoid glue bag, don't need you to handle, by the WEB server to completely;
Another is to define their own data structures, finally complete package, according to the data structure to parse the data,
Such as the two messages are split into three packages:
Figures 1 & lt; EN
D> Count
According to the 2 & lt; END>
Received the first to throw the cache together, and then parse,


Do you see this do:
I'll send data size,
Then send the data before and after (no sign)
When C receives the data until after the data size is equal to the data size for receiving end after

I do is to file transfer
1. DAT file name LENGTH1024
2. Cycle sending files
3. Close the file

C need to do is:
1. Receiving the file name and file size
2. The receive file data and compare whether to file size
3. Save the file
Disconnect the network connection

CodePudding user response:

This design no problem

CodePudding user response:

reference Runnerchin reply: 3/f
so design no problem


Thanks to the ^_^,
I think again

CodePudding user response:

For whether or not on receiving, whether the first receive contains twice to end send; Basically see your sending interval, the interval of if you small, such as after the first 200 byte, sent a second 200 byte directly; So to end a receiver is likely to contain the second 200 bytes, if the interval is larger, such as 1 s, then receive contains the possibility of a second sent 200 bytes is small,
Has something to do with the sending interval, if don't want to have crossed, that is the first to send, guarantee to end after, at this time to send the second 200, then the Suggestions can each send 200, at a time could be extended interval, or make response to the client send a receiving data packages, this end receives response packet sending the next 200
  • Related