Home > Net > TCP repeatedly broken even after receiving less than client connection requests
TCP repeatedly broken even after receiving less than client connection requests
Time:11-09
Reference code is https://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs (v=versus 110). Aspx wrote
The service side Listen 2000 Found a TCP client testing tools created 2000 clients connect server and send the data at the same time, all broken after a few seconds, 7, 8 successive repeatedly so the client can't connect the server, See the server or in the LISTENING state netstat TCP 127.0.0.1:20000 0.0.0.0:0 LISTENING
Could you tell me how to troubleshoot this problem under the? Or what operation can lead to this problem?
CodePudding user response:
The server did not do, the client disconnect processing, socket server in the client disconnected after 5-10 or in the connection state, so in 2000 the client even when they fail!
CodePudding user response:
See if there is a lot of not completely broken connections
CodePudding user response:
You can use first tool, or program self-examination in some debugging data, such as memory usage, number of threads, thread count and IOCP thread pool of worker threads, etc.,
Also consider, change m_maxNumberAcceptedClients to Semaphor Slim , it takes up several support to view the current signal, If the signal occupies number has not been released, can lead to m_maxNumberAcceptedClients. WaitOne (); Blocked, leading to not continue to the next, the client can't connect the server,
There is code throws an exception if ProcessReceive and ProcessSend, will lead to CloseClientSocket (e); Didn't have a chance to get called, can lead to the connection of signal is going to occupy, has not been released,
CodePudding user response:
The server to do disconnect detection, such as writing is unusual, says disconnect, released at this time to connect the server, otherwise it will affect the connection back,
CodePudding user response:
The service side look at the connection of the netstat all kinds of state data, The client also use netstat to see the connection status, Doubt that connection
CodePudding user response:
TCP connection session after the break, take the initiative to open one will enter a state of timewait, for 120-240 seconds (depending on the operating system), in the meantime the session of the source port (random port) is not available, until the port number is released (see "TCP - IP," a book), a TCP connection to your client is too frequent, pressure test should be used to simulate multiple clients machine, instead of one,
Can use the netstat command to view the network session state,