Indy 9
TIdRemoteCMDServer
Hierarchy, Properties, Methods, Events, See Also, Unit: IdRemoteCMDServer
Implements a common ancestor for a multithreaded server that executes a command for a remote client connection.
TIdRemoteCMDServer = class(TIdTCPServer)
Unit
IdRemoteCMDServer
Description
TIdRemoteCMDServer is a TIdTCPServer descendant that implements a multithreaded server that accepts remote client connections in order to execute commands. TIdRemoteCMDServer implements event handlers that allow execution of the threaded client connection, and generation of result or error messages for the remote client.

TIdRemoteCMDServer provides a protected method that implements execution of a threaded client connection to the server. The default implementation handles validation of port numbers for the client connection, command execution and processing, and closing of the client connection. During execution, the client must provide a Null character (decimal 0) delimited list of arguments to the TIdRemoteCMDServer that includes:

  • Client port number for standard error output. The default value is 0 when standard error output is not used for the connection.

  • User name for use in authenticating the client connection in the Rexec protocol or the User ID on the client machine in the RSH protocol.

  • Password for use in authenticating the client connection in the Rexec protocol or the User ID on the host machine in the RSH protocol.

  • Command line and optional arguments to be executed by the server.

When a port number for standard error output is provided, the executing client thread will create a TCP connection that will connect to the client's remote port number indicated in the initial argument to the remote command server. In RSH, this is done using a local port number in the range 512 through 1023. The standard error connection is closed after execution of the command for the threaded client connection.

Note: TIdRemoteCMDServer is the ancestor for more specialized server implementations like TIdRexecServer an TIdRshServer, and contains an protected abstract virtual method that must be overridden in descendant classes to invoke execution of the command for a threaded client connection.


TIdRemoteCMDServer.SendError
TIdRemoteCMDServer, See Also
Sends an error message to either the standard error connection or the client connection.
procedure SendError(AThread: TIdPeerThread; AStdErr: TIdTCPClient; AMsg: String);
Parameters
AThread: TIdPeerThread
Threaded client connection for the error message.
AStdErr: TIdTCPClient
Standard error connection to use for the error message.
AMsg: String
Error message to send to the client connection.
Description
SendError is a procedure used to send the error message in AMsg to the threaded client connection in AThread using the standard error connection in AStdErr. SendError writes the value #1 (Decimal 1) to the connection in AThread to indicate that an error condition has occurred. When AStdErr contains a valid TCP connection for a non-zero client port number, the error message in AMsg is written to the connection in AStdErr. When AStdErr dopes not contain a valid TCP connection, the error message in AMsg is written to the connection in AThread.

Use SendResult to return values that occur during successful execution of the command for the client connection.


TIdRemoteCMDServer.SendResults
TIdRemoteCMDServer, See Also
Sends the results from remote command execution to a client connection.
procedure SendResults(AThread: TIdPeerThread; AStdErr: TIdTCPClient; AMsg: String);
Parameters
AThread: TIdPeerThread
Threaded client connection for the error message.
AStdErr: TIdTCPClient
Standard error connection to use for the error message.
AMsg: String
Error message to send to the client connection.
Description
SendResults is a procedure used to send the results from successful execution of command for a client connection to the TIdRemoteCMDServer instance. SendResults write a Null character (Decimal 0) to the client connection in AThread to indicate that the remote command was completed successfully, followed by the value in AMsg.

Use SendError to return an error message that occurs during execution of the command for the client connection.


Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.