Skip to main content

File Transfer Functions and FTP Commands

IV. FILE TRANSFER FUNCTIONS​

The TELNET connections on which FTP commands and replies are transmitted, are initiated by the user-FTP process via an ICP to a standard server socket. FTP commands are then transmitted from user to server, and replies are transmitted from server to user. The user file transfer functions invoive sending the FTP commands, interpreting the replies received and transferring data over the data connection in the specified manner. The server file transfer functions involve accepting and interpreting FTP commands, sending replies, setting up the data connection, and transferring data.

IV.A FTP Commands​

FTP commands are ASCII terminated by the ASCII character sequence CRLF (Carriage Return follow by Line Feed). The command codes themselves are ASCII alpabetic characters terminated by the ASCII character 'space' (code = 32.). For convenience, the command codes are defined to be four (or less) ASCII alphanumeric characters (including both upper and lower case alphabetic characters). The command codes and the semantics of commands are described in this section, but the detailed syntax of commands is specified in Section V.b, the reply sequence are discussed in Section V.C, and scenarios illustrating the use of commands are provided in Section V.D.

FTP commands may be partitioned as those specifying access-control identifiers, data transfer parameters, or FTP service requests.

IV.A.1 Access Control Commands​

The following commands specify access control identifiers (command codes are shown in parentheses).

User name (USER) - The argument field is an ASCII string identifying the user. The user identification is that wich is required by the server for access to its file system. This command will normally be the first command transmitted by the user after the TELNET connections are made (some servers may require this). Additional identification information in the form of pasword command may also be required by some servers.

Password (PASS) - The argument field is an ASCII string identifying the user's password. This command must be immediately preceded by the user name command, and together it completes the user's identifecation for access control.

IV.A.2 Data Transfer Commands​

All data transfer parameters have default values, and the commands specifying data transfer parameters are required only if the default parameter values are to be changed. The default value is teh last specified value, or if no value has been specified, the standard default value specified here. This implies that the server must "remember" the applicable default values. The commands may be in any order except that they must precede the FTP service request. The following commands specify data transfer parameters.

Byte size (BYTE) - The argument is an ASCII-represented decimal integer (1 through 255), specifying the byte size for the data connection for local byte and image representation types. The default byte size is 8 bits. The byte size is always 8 bits in the ASCII and Print file representation types. A server may reject specific byte size/type combinations by sending an appropriate reply.

Data socket (SOCK) - The argument is a HOST-socket specification for the data socket to be used in data connection. There may be two data sockets, one from server to user and the other for user to server data transfer. An odd socket number defines a send socket and an even socket number defines a receive socket. The default HOST is the user HOST to which TELNET connections are made. The default data sockets are (U+4) and (U+5) where U is the socket number used in the TELNET ICP and the TELNET connections are on sockets (U+2) and (U+3).

Representation Type (TYPE) - The argument is a single ASCII character code specifying the representation types described in section III.B. The following codes are assigned for type:

A - ASCII
I - Image
L - Local Byte
P - Print file in ASCII
E - EBCDIC print file

The default representation type is ASCII

File Structure (STRU) - The argument is a single ASCII character code specifying file structure described in section III.C. The following codes are assigned for structure:

F - File (no record structure)
R - Record structure

The default structure is File (i.e., no records).

Transfer Mode (MODE) - The argument is a single ASCII character code specifying the data transfer modes described in Section III.C. The following codes are assigned for transfer modes:

S - Stream (bytes, close is EOF)
B - Block (Header with descriptor and count)
T - Text (TELNET control mode for EOR, EOF)
H - Hasp (specially formatted compressed data)

The default transfer mode is Stream.

IV.A.3 FTP Service Commands.​

The FTP service commands define the file transfer or the file system function requested by the user. The argument of an FTP service command will normally be a pathname. the syntax of pathnames must conform to server site conventions (with standard defaults applicable), except that ASCII characters must be used (in conformance with the TELNET Protool). The suggested default handling is to use the last specified device directory or file name, or the standard default defined for local users. The commands may be in any order except that a "rename from" command, must be followed by a "rename to" command, and some servers may require an "allocate" command before a "store" command. The data when transferred in response to FTP service commands shall always be over the data connection. The following commands specify FTP service requests:

Retrieve (RETR) - This command achieves the transfer of a copy of file specified in pathname, from server to user site. The status and contents of a file at server site shall be unaffected.

Store (STOR) - This command achieves the transfer of a copy of file from user to server site. If file specified in pathname exists at the server site, then its contents shall be replaced by the contents of the file being transferred. A new file is created at the server site if the file specified in pathname does not already exist.

Append (with create) (APPE) - This command achieves the transfer of data from using to serving site. If file specified in pathname exists at the server site, then the data transferred shall be appended to that file, otherwise the file specified in pathname shall be created at the server site.

Rename from (RNFR) - This command specifies the file which is to be renamed. This command must be immediately followed by a "rename to" command specifying the new file pathname.

Delete (DELE) - This command causes teh file specified in pathname to be deleted at the server site. If an extra level of protection is desired (such as the query, "Do you really wish to delete?"), it should be provided by the user-FTP process.

List (LIST) - This command causes a list to be sent from server to user site. If pathname specifies a directory, the server should transfer a list of files in the specified directory. If pathname specifies a file then server should send current information on the file. This command may be used to obtain the contents of a file directory (the response should be sent in ASCII type) or test the existence of a file and its current status.

Allocate (ALLO) - This command my be required by some servers to reserve sufficient storage to accomodate the new file to be transferred. The command field shall be a decimal integer representing the number of bytes (of size specified by the byte size command) of storage to be reserved for the file. This command shall be followed by a store or append command. The ALLO command should be treated as a NO-OP (no operation) by thuse servers which do not require that the maximum size of the file be declared beforehand.

Restart (REST) - The argument field represents the server marker at which file transfer is to be restarted. This command does not cause file transfer but "spaces" over the file to the specified data checkpoint. This command shall be immediately followed by the appropriate FTP service command which shall cause file transfer to resume.

Status (STAT) - This command shall cause a status response to be sent over the TELNET connection in form of a reply. The command may have an argument field such as a pathname. if the argument is a pathname, the command is analogous to the "list" command except that data shall be transferred in ASCII on the TELNET connection. If no argument is specified, the server should return general status information about the server FTP process. This may include service availability, the current settings for the relevant FTP parameters (including default settings), and the status of command execution and connections.

Abort (ABOR) - This command indicates to the server to abort the previous FTP service command and any associated transfer of data. The abort command should be preceded by the TELNET SYNCH condition (indicated by the combination of the DATA MARK and the INS). No action is to be taken if the previous command has been completed (including data transfer). The TELNET connections is not to be closed by the server, but the data connection may be closed. An appropriate reply should be sent by the server.

Logout (BYE) - This command terminates a USER and if file transfer is not in progress, closes the TELNET connection. If file transfer is in progress, the connection will remain open for result response and will then close. During the interim a new USER command (and no other command) is acceptable.

An unexpected close on TELNET connection will cause the server to take the effective action of an abort (ABOR) and a logout (BYE).