Subj : Re: Socket programmation with threads To : comp.programming.threads From : David Schwartz Date : Tue May 24 2005 11:12 am "Phil Frisbie, Jr." wrote in message news:ylIke.1856$W51.14418@typhoon.sonic.net... > christophe.anthon@gmail.com wrote: >> Well I wanted to program an C++ Chat program, so I need threads in the >> server so that he can handle many incoming connections and that what >> they send. > A chat server has very low overhead compared to other common servers. > Sure, you can use a thread per connection for a few hundred connections, > but you can create a single threaded chat server that can handle tens of > THOUSANDS of connections using /dev/poll or similar techniques. Yes, but it will suffer from burstiness under load. For example, if one client hits a code path that has not yet faulted in, and the local disk is busy, the whole server will stall while the code faults in. Once the server has stalled, it is operating against a backlog. Unless you are very careful to ensure the code becomes more efficient as the backlog goes up, you may never catch back up from the stall. You do much better to use a few threads to make sure that an unexpected stall doesn't take down the server. DS .