2

I am developing a Server that should handle many requests, I`m using Delphi and Indy Library. Each request/connection has it's own thread, I want to send message from Server to Client, I have a Thread-List that holds Client Contexts and keep connections alive, when I want to send message from server I pick the client context from this list and send message to it.

There are many connections and many threads, The question is if I save and keep all contexts, will threads be alive ? if yes, is it possible to use Thread-Pool ( TIdSchedulerOfThreadPool ) in this situation ?!

Is there a way to send message from server to client without keeping connection threads alive ?

Mahmoud_Mehri
  • 1,643
  • 2
  • 20
  • 38
  • 4
    The contexts are tied to the threads. When a context is disconnected, its thread is stopped (or put back in the pool) and the context is destroyed. If a thread stops, it's current context is disconnected and destroyed. There is a 1:1 relationship between thread and context while a client is alive. They cannot be separated – Remy Lebeau Dec 02 '17 at 16:55
  • @RemyLebeau Tanks, So for example when 10000 Clients Connected, there is 10000 contexts and 10000 threads, is`t it a performance issue ? – Mahmoud_Mehri Dec 02 '17 at 17:43
  • @G3ntle_Man: you won't even get that far in a 32bit process (theoretical limit is 2048 threads) – whosrdaddy Dec 02 '17 at 18:58
  • @whosrdaddy that is true only for a 32bit process without LAA on a 32bit system. A 32bit process with LAA on a 32bit system, and a 32bit process on a 64bit system, can create more than 2048 threads (but still not 10000). A 64bit process can create vastly more threads (55000). See [Pushing the Limits of Windows: Processes and Threads](https://blogs.technet.microsoft.com/markrussinovich/2009/07/05/pushing-the-limits-of-windows-processes-and-threads/) for more details – Remy Lebeau Dec 02 '17 at 19:30

0 Answers0