Home > Net >  C # socket. The problem of the Receive always delay for a few seconds
C # socket. The problem of the Receive always delay for a few seconds

Time:09-27

Start socket listening news letter from a third party, regardless of the packet size, even if it is only 10 byte, socket. The Receive to wait after N seconds to finish

For example code

Console. WriteLine (" is ready to receive data ");
Clientsocket. The Receive (bytes); - & gt; Here always need to fixed N seconds, regardless of the packet size
Console. WriteLine (" receiving data ");


Have to know what's going on?

CodePudding user response:

If excluding network, you are blocking worker threads in other places

CodePudding user response:

The N SEC how did you get?

CodePudding user response:

refer to the second floor by_ love reply:
N seconds how did you get this?


The first output is ready to receive

The second output receive complete

Two printing time is always bad for 10 seconds

CodePudding user response:

reference 1st floor Eason0807 response:
if excluding network, you are blocking worker threads in other places


The three lines of code, print input time fixed difference before and after 10 seconds, if it's a blocking in other blocks?

Simply write a server and client code, no obstruction, is when the server receives data from the third party, always like this

CodePudding user response:

Code, which can't guess!!!!!
  •  Tags:  
  • C#
  • Related