Efficient Threading

Guys,

Creating an app that's essentially a Telnet server.

At the moment, I've got two threads:

1) Listens for connections and accepts them
2) Checks to see if any clients have sent data that is waiting to be read.

Is that enough for a basic Telnet server, considering that I may have up to 2000 connections online at once Or should I have a thread for each client

Cheers, everybody!

Will



Answer this question

Efficient Threading

  • djee

    You don't want you application to have many more active threads than you have processors in your system. Each thread will consume valuable system resources.

    Use the asynchronous methods to read/write data from/to and accept new connections. Consider using the thread pool if you need to call a blocking method.

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnpag/html/scalenet.asp probably has more information than what you want :)

    Best regards,
    Johan Stenberg



  • Koen Verschueren

    WIll everyone here is not a guy.

    There is an advanced technique called connection pooling

    You don't keep 2000 connections you create just enough connections to handle what is actually transpiring at the moment.



  • HarmonicSoftware

    Renee,

    Apologies. I use the same expression for the ladies among us, too!

    Will


  • Efficient Threading