I have just learned that you can use a Thread pool for multi client TCP-connections, I have an C# application today that I like to implement this to. I have read some, for example the first answer to this question ( Best way to accept multiple tcp clients? ), but I dont really get how to make the last adjustments to work with my “needs”. I have a messagehandeling function for each connection (each connection is 2 threads, one for recieving/sending messages (connection open for a long duration moste of the time) and one for doing Tasks depending on the messages (also creates answers to send back). I would now like to use the recieving method in the link below, but how can I do this with a thread pool in my example?
If anything is unclear, just ask questions!
/Nick
Just avoid having one thread per connection. It generate lot of overhead on the OS and doesn’t scale well.
Today we use NIO : non blocking I/O. One thread can handle 10k+ connections. There are very easy way to use them, like NodeJs for example. NIO libraries are available for most platform/languages (Netty for Java, NodeJs with javascript,…).
You should specify wich language/environement you are using.