Indy 9 | Content | Index | Reference

TIdDataChannelThread
Hierarchy, Properties, Methods, Events, See Also, Unit: IdFTPServer
Implements a threaded data channel for an FTP client thread,

    TIdDataChannelThread = class(TIdThread)

Unit
IdFTPServer
Description
TIdDataChannelThread is a TIdThread descendant that implements the data channel used when a threaded FTP client connection needs to read or write data using the FTP STOR, STOU, APPE, RETR, LIST, or NLST command verbs.

TIdDataChannelThread provides properties that represent the connection used for an acive or passive data channel for the FTP client, the control channel from the threaded client, and TIdRFCReply properties representing the success and error messages used when performing data transfer. TIdDataChannelThread provides methods that create the active or passive connection, initialize the data channel, or start the thread of execution.

TIdDataChannelThread can represent an active or a passive connection type on the data channel. When passive connections are used, the connection is constructed as a TIdSimpleServer object instance. When the TIdDataChannelThread thread is started, the data channel will be used to listen for a client connection.

When active connections are opened by the client thread, the connection is constructed using a TIdTCPClient object instance bound to the FTP data port 20. When the TIdDataChannelThread thread is started, the data channel will be connected.

During execution, the data channel thread uses the Data property to access the TStrings or TStream values used during the data transfer operation. After performing the transfer operation, the socket for the data channel in the thread is disconnected, and the Success or Error message is written using the control channel for the threaded client connection. The data channel thread is stopped after execution of the transfer operation.

TIdDataChannelThread is the thread type created for use in the TIdFTPServerThread.DataChannel property in a threaded client connection. The data channel thread exists for the lifetime of the threaded client connection. It is initalized and started prior to data transfer operations, and suspended when the data transfer operation is completed.

TIdDataChannelThread.ErrorReply
TIdDataChannelThread
Error message used during data transfer operations.

    property ErrorReply: TIdRFCReply;

Description
ErrorReply is a TIdRFCReply property that represents the message sent to a client connection when an error occurs during startup of the threaded data channel, or when the thread executes to perform data transfer.

Use OKReply to specify the message used when a data transfer operation is successful.

TIdDataChannelThread.OKReply
TIdDataChannelThread
Success message used during data transfer operations.

    property OKReply: TIdRFCReply;

Description
OKReply is a TIdRFCReply property that represents the message sent to a client connection when a data transfer operation has been successfully completed during execution of the threaded data channel. or when the thread executes to perform data transfer.

Use ErrorReply to specify the message used when an error occurs during a data transfer operation.

TIdDataChannelThread.Create
TIdDataChannelThread
Constructor for the object instance.

    constructor Create(APASV: Boolean; AControlConnection: TIdTCPServerConnection; const ADefaultDataPort: Integer = IdPORT_FTP_DATA); reintroduce;

Parameters
APASV: Boolean
Indicate if passive connections are used to open the data channel.
AControlConnection: TIdTCPServerConnection
Threaded FTP client connection that is the control channel for the FTP session.
Description
Create is the constructor for the object instance, and calls the inherited Create method. Create also sets properties for the threaded data channel, including the following:

- StopMode - smSuspend

- ControlChannel - Control channel for the client connection.

Create also allocates resources need for object properties, including:

- OKReply

- ErrorReply

- DataChannel

When the threaded data channel uses Passive connections, as indicated in APASV, DataChannel will refer to a TIdSimpleServer object instance bound to the IP address used in the ControlChannel for the thread. When active connections are used, DataChannel will refer to a TIdTCPClient bound to port number 20, as required by the FTP protocol.

TIdDataChannelThread.Destroy
TIdDataChannelThread
Frees an object instance.

    destructor Destroy; override;

Description
Destroy is the destructor for the object instance. Destroy frees and releases resources allocated in the Create constructor, including OKReply, ErrorReply, and DataChannel. Destroy calls the inherited method prior to exiting.

TIdDataChannelThread.SetupDataChannel
TIdDataChannelThread
Configures the IP address and Port number used for the data channel.

    procedure SetupDataChannel(const AIP: string; APort: Integer);

Parameters
const AIP: string
IP Address for the data channel.
APort: Integer
Port number for the data channel.
Description
SetupDataChannel is a procedure that allows the threaded data channel to be configure the socket connection used when the data channel is started or executed. When passive connections are used, SetupDataChannel will assign the IP address and Port number specified in AIP and APort to the BoundIP and BoundPort properties in the TIdSimpleServer object instance that represents the data channel. When active connections are used, SetupDataChannel will assign AIP and APort to the Host and Port properties in the TIdTCPClient object instance that represents the data channel.

SetupDataChannel is used when TIdFTPServer responds to the FTP PORT or PASV command verbs from a thread FTP client connection.

TIdDataChannelThread.StartThread
TIdDataChannelThread
Prepares and executes the data channel thread.

    procedure StartThread(AOperation: TIdFTPOperation);

Parameters
AOperation: TIdFTPOperation
Action to be performed on the data channel.
Description
StartThread is a procedure that allows the threaded data channel to be prepared and executed to perform the data transfer operation identified in AOperation. The data channel thread exists for the lifetime of the threaded client connection. It is initalized and started prior to data transfer operations, and suspended when the data transfer operation is completed.

StartThread determines the socket connection type required for the active or passive client connection, and performs the actions needed to allow the client connection for the DataChannel. When passive connections are used, the TIdSimpleServer object instance in DataChannel will be used to listen for the client connection. When active connections are used, the TIdTCPClient object instance in DataChannel will be connected.

Use SetupDataChannel to configure the IP address and port number to used for the differing client connection types.

If an exceptionm occurs while establishing the connection for DataChannel, the values in ErrorReply are written to the FTP client using the ControlChannel.

When successfully completed, StartThread will begin execution of the threaded data channel for use with FTP data transfer operation.

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