Home > other >  TCP communications the Send and Recv problem
TCP communications the Send and Recv problem

Time:10-10

I now use the send a number to send a, recv thread correctly received data, the data is very small, only about five characters, so every time to send, receive the data, but I use the send data sent 10 times in a row, and then use the recv receiving, recv after receiving will perform a series of judgment, lead to the send to send data after recv haven't returned to the blocking state of data received, to receive data after less than a second time,
I've tried, after the send, use the Sleep (500) and then send the second data to Sleep (500),,, can receive a print all information, more certain is the above questions,
I now the question is, I use the MFC button, press the send mobile data, pop-up send stop data, two interval time is very short, I want to, how to ensure that two data can be sent to lower their to correct,

CodePudding user response:

The file descriptor or handle set to try a non-blocking mode!

CodePudding user response:

Established by the TCP connection, send data, you will find that every time the recv the data received is not necessarily complete, packet unpacking processing needs to be done
  • Related