I'm developing a server with many client requests. According to the type of requests, I want to use a separate TIdCmdTCPServer
for each type of request.
In fact, it's an Accounting software that I want to separate each service with a separate TIdCmdTCPServer
, for example one for Accounting, another one for Inventory, and so on.
Every TIdCmdTCPServer
will have its own set of command handlers, and will be listening to its own port, but all will be activated on the same IP and running in the same application.
What is the disadvantage of this approach?
Can I use a single TSchedulerThreadPool
shared by all of the TIdCmdTCPServer
s? Or should I use a separate TSchedulerThreadPool
for each one?
There is nothing wrong with what you propose. The main disadvantage is just in using more system resources to maintain multiple servers in memory, and using multiple ports (which are a finite resource). But other than for code organizational purposes, there is no real advantage over just using a single port and defining your protocol to expose multiple subsets of commands that a client can choose from.
At the very least, a single TIdCmdTCPServer
can listen on multiple ports via its Bindings
collection, and your command handlers can look at which port each request comes from, if needed. Or, you can switch to a standard TIdTCPServer
and use multiple manual TIdCommandHandlers
collections, one for each binding.
And no, you cannot share schedulers across multiple servers. Each server requires its own scheduler. But a single server with multiple bindings needs only 1 scheduler.