Requests to the server pass through time, here is the server code. Why it happens?

public Server(int port) { Listener = new TcpListener(IPAddress.Any, port); Listener.Start(); while(true) { ThreadPool.QueueUserWorkItem(ClientThread, Listener.AcceptTcpClient()); } } void ClientThread(Object StateInfo) { new Client((TcpClient)StateInfo); } 

Here is the Main method:

  static void Main(string[] args) { int MaxThreadsCount = Environment.ProcessorCount * 100; ThreadPool.SetMaxThreads(MaxThreadsCount, MaxThreadsCount); ThreadPool.SetMinThreads(2, 2); new Server(8080); } 

Here is a screen request: a busy cat

PS: the processor is 8 core, so the number of processes can go up to 800

UPD: Posted by Console.Clear () and the problem disappeared, can anyone explain why?

  void ClientThread(Object StateInfo) { Console.Clear(); new Client((TcpClient)StateInfo); } 
  • It depends on the browser. And what is the actual trouble (problem)? Maybe the browser creates 4 sockets to provide a “fast” Internet. - nick_n_a
  • @nick_n_a, the problem is that for some reason, sometimes the browser shows that the connection was dropped when the page was frequently updated - Fexolm
  • Try stackoverflow.com/questions/1724596/… this example. I also tried to accept Accept myself and caught the same error. Made through the pool as in the example. - nick_n_a
  • @nick_n_a, tried it, but the problem remained (became a little less frequent), attached a screenshot - Fexolm
  • one
    Show the class Client - surely the same error in it ... - Pavel Mayorov

0