Home > Software engineering >  Send and receive multiple client socket how to management?
Send and receive multiple client socket how to management?

Time:11-07

Note: oh, I'm not talking about the inside of the server client socket oh
But as a client. Exe inside open multiple clients link different service IP
But there is a problem, if I open a client to open a thread to receive package, so I am going to open 200 server connection 200 threads, this overhead is too big,
So is there any way to create a thread or a few threads at the same time manage the link server client socket to receive packages or other function?

CodePudding user response:

Think about this question: connect to a server to new pclient, if the link 200 different server, will be 200 new pclient, article 200 after the thread to wait for the server side after the contract package, the cost is too big,

If you open one or more threads, thread inside a blocking function, which the client had a message response which processing package, and so on, this just like server management, but don't know how this figure,

CodePudding user response:

Certainly not so multithreading, is a thread used again and again

CodePudding user response:

Server or connection from different clients (IP), what's the difference?

Select directly, poll or epoll did it soon

CodePudding user response:

Under Windows, select, WSASynSelect, events and iocp
The simplest is the select. The readable,
If (CanRead (s)) {
The recv ();
}

CodePudding user response:

Consult
https://www.cnblogs.com/renyuan/p/5100296.html

CodePudding user response:

Using the completion port.
  • Related