Internet Direct (Indy)
Home
PreviousUpNext
TIdCmdTCPServer Class

Implements a multi-thread TCP/IP-based server with support for command handlers.

Pascal
TIdCmdTCPServer = class(TIdTCPServer);

TIdCmdTCPServer is a TIdTCPServer descendant that implements a multi-thread TCP/IP-based server with support for command handlers. 

Command handlers provide an extensible mechanism for definition of the commands and their associated data as used in protocol exchanges for client connections to the server. Command handlers provide access to the properties and methods in the server and/or the client context that are affected in the processing required for the command. 

Use of command handlers is an optional feature enabled when CommandHandlersEnabled is set to True. Descendant classes must implement the InitializeCommandHandlers method that creates the default command handlers needed to support the command, processing, and responses required for a specific protocol. 

When CommandHandlersEnabled is set to False, the OnExecute event handler in the server is used to implement execution of the task for a client connection. 

TIdCmdTCPServer implements properties containing responses used in the server, including: 

 

During initialization of the server component, the standard reply classes (TIdReplyRFC, TIdRepliesRFC) for the server are used to create default response values in properties, including: 

 

Property 
Code 
Text 
200 
Welcome 
300 
Too many connections. Try again later. 
400 
Unknown Command 
500 
Unknown Internal Error 
100 
Help follows 

 

During activation of the server (when Active is set to True), command handlers are created using the InitializeCommandHandlers method. InitializeCommandHandlers must be called only at runtime, after component streaming, and when the command handler collection has not been previously initialized. When HelpReply is assigned, a command handler for the "Help" command is dynamically created for items in the command handler collection and added to the help response for the server. 

One or more listener threads are created using the definitions found in the Bindings property for the server. Listener threads accept new connections to the server, and create the executable tasks used in the Scheduler

 

When CommandHandlersEnabled contains False, the OnExecute event handler is used control executiuon of the client context for each connection. When CommandHandlersEnabled contains True, the server reads the command and data from the client context and provides the values to the command handlers for the server.

Internet Direct (Indy) version 10.1.5
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Website http://www.indyproject.org.
Post feedback to the Indy Documentation newsgroup.