There is a lot to it, hard to answer all together.
Also, I don't know your setting. What do you want, a Web Service? Web application? P2P chat?
Just a few ideas. First principal: don't create a thread per client! All clients should be served by one thread. The number of threads should be fixed or configurable, created once per server's lifetime: something like this: main thread, one thread for database, one or two threads for listening for new users and authentication, one common thread for user interactions. The threads can communicate through the blocking message queue (I have a generic queue implementation, a faster implementation is available in the Framework v. 4.0).
You can find some idea in my past Answers. Sorry, they are written in response to different Question ans some items can be irrelevant, but you also did not provide exact information on what you want. Please see:
Multple clients from same port Number[
^]
Thread wrapper, very useful to avoid the problem of passing parameters:
How to pass ref parameter to the thread[
^]
Collection of other related references:
How to get a keydown event to operate on a different thread in vb.net[
^]
My article on blocking message queue, full code with usage samples:
Simple Blocking Queue for Thread Communication and Inter-thread Invocation[
^].
It all needs certain study. Further details highly depend on you requirements and decisions. Hope it can help you.
Good luck,
—SA