TIdTrivialFTP
Implements a Trivial File Transfer Protocol client.
Unit
Description
TIdTrivialFTP is a
TIdUDPClient descendant that implements a Trivial File Transfer Protocol (TFTP) client as described in the Internet Standards documents:
- RFC 1350 - Trivial File Transfer Protocol (http://www.rfc-editor.org/rfc/rfc1350.txt)
- RFC 1782 - TFTP Option Extension (http://www.rfc-editor.org/rfc/rfc1782.txt)
- RFC 1783 - TFTP Blocksize Option (http://www.rfc-editor.org/rfc/rfc1783.txt)
Trivial FTP is an extremely lightweight and simple UDP-Based file transfer protocol that is normally used read and write files from/to a remote server. TFTP cannot list directories, and currently has no provisions for user authentication.
TIdTrivialFTP supports the TFP Option Negotiation Protocol where the client appends options at the end of the Read Request or Write request packet. TIdTrivialFTP also supports the TFTP Blocksize Option which allows the client and server to negotiate a blocksize more applicable to the network medium.
Specifies the event handler when data is sent or received.
Description
OnWork is a
TWorkEvent property that represents the event handler triggered when a
Get or
Put request has been made, and the method is started. When AWorkMode is wmRead Mode (
Get method) or wmWrite Mode (
Put method), the amount of data transmitted is available in ACount.
Specifies an event handler for a data request.
Description
OnWorkBegin is an event handler that allows the TFTP client to respond to a
Get or
Put request notification. OnWorkBegin is triggered when has been made, and is about to begin transferring data.
Work mode will contain wmRead for Get operations, and wmWrite for Put operations.
Specifies an event handler for a complete file operation.
Description
OnWorkEnd is an event handler that allows the TFTP client to respond to a complete file operation. OnWorkEnd is triggered when a request has been made and the method completes. Work mode will contain wmRead for
Get operations or wmWrite for
Put operations.
Identifies of bytes to transmit before an acknowledgement is required.
property RequestedBlockSize: Integer;
Description
RequestedBlockSize is an Integer property that identifies the number of bytes to use as Block when reading or writing file data on the TFTP server. Normally a file cannot be transmitted in a single block. RequestedBlockSize specifies the number of bytes that can transmitted before an acknowledgement is required.
The default value for RequestedBlockSize is 1500. Note: Changing the value of RequestedBlockSize can adversely affect the performance of the protocol.
Specifies the transfer mode for data on TFTP connection.
Description
TIdTFTPMode is an enumerated type that specifies the transfer mode for data on TFTP connection, and can contain the values tfNetAscii and tfOctet.
tfNetAscii indicates that the connection will transmit data using the netascii, or "USA Standard Code for Information Interchange", format defined in the Telnet protocol specification. tfNetAscii will contain 8-bit ASCII data.
tfOctet indicates that the connection will transmit raw 8-bit data, or binary data.
Creates a new object instance.
constructor Create(AnOwner: TComponent); override;
Parameters
AnOwner: TComponent
Owner of the object instance.
Description
Create is the constructor for the object instance, and creates a new
TIdTrivialFTP component. Create sets the default port to the standard port number used for the TFTP protocol (
IdPORT_TFTP). The constructor also sets
TransferMode to tfOctet,
RequestedBlockSize to 1500, and ReceiveTimeout to 4000.
Retrieve a file from a TrivialFTP server.
procedure Get(const ServerFile: String; DestinationStream: TStream); overload;
procedure Get(const ServerFile: String; const LocalFile: String); overload;
Parameters
const ServerFile: String
DestinationStream: TStream
Destination for retrieved file data.
const LocalFile: String
File name on the local file system.
Description
Get is an overloaded method to retrieve a file from a TrivialFTP server.
The version requiring a local filename creates a TFileStream, then calls the stream version of the Get method (it is freed automatically).
The stream version of the Get method transmits the stream, firing the onWork, onWorkBegin, onWorkEnd during the process.
Retrieve a file from a TrivialFTP server.
procedure Get(const ServerFile: String; DestinationStream: TStream); overload;
procedure Get(const ServerFile: String; const LocalFile: String); overload;
Parameters
const ServerFile: String
DestinationStream: TStream
Destination for retrieved file data.
const LocalFile: String
File name on the local file system.
Description
Get is an overloaded method to retrieve a file from a TrivialFTP server.
The version requiring a local filename creates a TFileStream, then calls the stream version of the Get method (it is freed automatically).
The stream version of the Get method transmits the stream, firing the onWork, onWorkBegin, onWorkEnd during the process.
Sends a file to a TrivialFTP server.
procedure Put(SourceStream: TStream; const ServerFile: String); overload;
procedure Put(const LocalFile: String; const ServerFile: String); overload;
Parameters
SourceStream: TStream
Contains the data to be sent to the TFTP server.
const ServerFile: String
File name of the TFTP server.
const LocalFile: String
File name on the local file system.
Description
Put is an overloaded method to
send a file to a TrivialFTP server.
The version requiring a local filename creates a TFileStream, then calls the stream version of the Put method (it is freed automatically).
The stream version of the Put method transmits the stream, firing the onWork, onWorkBegin, onWorkEnd during the process.
Sends a file to a TrivialFTP server.
procedure Put(SourceStream: TStream; const ServerFile: String); overload;
procedure Put(const LocalFile: String; const ServerFile: String); overload;
Parameters
SourceStream: TStream
Contains the data to be sent to the TFTP server.
const ServerFile: String
File name of the TFTP server.
const LocalFile: String
File name on the local file system.
Description
Put is an overloaded method to
send a file to a TrivialFTP server.
The version requiring a local filename creates a TFileStream, then calls the stream version of the Put method (it is freed automatically).
The stream version of the Put method transmits the stream, firing the onWork, onWorkBegin, onWorkEnd during the process.