there.
I am trying to program a server.
The server receive some information from client
and it sends the information to the other server and it receive the response.
Do I need to use select() on this case?
or Pthread only is enough to do this.
my server has many clients connecting concurrently
please answer me kindly.
And if there is, please tell me the source code or site that I can refer to
One approach to implementing a server that handles multiple clients is to create a pthread for each client connection, so that you can read/write each connection in a dedicated thread. It sounds like what you’re asking is “if I have a pthread for each client connection, do I still need to use
select?”In a very simple server you might be able to dispense with
select: the connection thread looks something like:But, even with a dedicated client thread, you may find that you still want to use
selectto check for available input before callingreadon the client connection. For example, if you need to be able to implement an idle timeout on your connection, you won’t want to just do a blockingread.