Home > Software engineering >  Consult a small problem, WSASend send packets
Consult a small problem, WSASend send packets

Time:09-20

In a single thread, note: there is only one thread calls WSASend, then keep sending packets
The client because the network reason may receive slowly

Question 1:
WSASend first send text is: 1, the second time send text is: 2, the third is: 3



Question 2:
WSASend will ensure that the client how can you ensure that according to the order received, the first to receive is 1, the second received is 2,
The client will receive the 2 first, after receiving 3?

The client could be one-time receives 123?

Note: the client is ordinary single thread receives calls a: : recv (), not to use any overlap

CodePudding user response:

Multithreaded send a socket at the same time, you can't guarantee the data sequence, WSASend,

CodePudding user response:

I said is a single thread, can ensure that same order?

CodePudding user response:

reference 1st floor smwhotjay response:
multithreaded send a socket at the same time, you can't keep data sequence, WSASend,


I said is a single thread, can ensure that same order?

CodePudding user response:

Without failure cases to ensure the order is received, but can be by 123 at the same time, the stick pack is a must to consider



CodePudding user response:

Send 1 after the success again send 2 to ensure the order

CodePudding user response:


Send 1 after a successful guarantee the order will be send 2



Brother, are you? How old are irrelevant answer?




Without failure cases to ensure the order is received, but can be by 123 at the same time, the stick pack is a must to consider

Thank you, if so, the client receives the first 1 byte, and the rest of the receiving part, will order?
At this time without receiving data is in what position, in the memory? Or in the Windows kernel?



CodePudding user response:

reference 5 floor smwhotjay reply:
send 1 to ensure order after the success again send 2

Send 1 after a successful guarantee the order will be send 2


Brother, are you? How old are irrelevant answer?

CodePudding user response:

My understanding is WSASend does not ensure that the client according to the order received, but TCP or UDP protocol, protocol is dedicated to do these things, to ensure that the data sequence, completeness, correctness, WSASend first action should be your data copies to send buffer, as long as you order, the memory copy is order

CodePudding user response:

Don't know how many predecessors in the TCP Socket
Send (many) send (less) send (wealth)
Has been so much illness recv (), recv (wealth)
Inside the trap!
http://bbs.csdn.net/topics/380167545

CodePudding user response:

The
refer to the original poster TLBBSFF response:
in a single thread, note: there is only one thread calls WSASend, then keep sending packets
The client because the network reason may receive slowly

Question 1:
WSASend first send text is: 1, the second time send text is: 2, the third is: 3
Question 2:
WSASend will ensure that the client how can you ensure that according to the order received, the first to receive is 1, the second received is 2,
The client will receive the 2 first, after receiving 3?
The client could be one-time receives 123?
Note: the client is ordinary single thread receives calls a: : recv (), what won't use overlapping


The client is likely a received 123
The reason is that TCP is based on the flow
  • Related