IV. File Transfer Functions (Access Control and Transfer Parameter Commands)
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 involve 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 strings terminated by the ASCII character sequence CRLF (Carriage Return followed by Line Feed). The command codes themselves are ASCII alphabetic characters terminated by the ASCII character 'space' (octal code 40). 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 sequences 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. Certain commands (such as ABOR, STAT, BYE) may be sent over the TELNET connections while a data transfer is in progress. Some servers may not be able to monitor the TELNET and data connections simultaneously, in which case these commands should be preceded by a TELNET SYNC to awaken the server. (For other servers this may not be necessary and the SYNC will be ignored.)
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 which 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 a password and/or an account command may also be required by some servers. Servers may allow a new USER command to be entered at any point in order to change the accounting information. All parameters are unchanged and any file transfer in progress is completed under the old account.
Password (PASS) - The argument field is an ASCII string identifying the user's password. This command must be immediatly preceded by the user name command, and, for some sites, completes the user's identification for access control. Since password information is quite sensitive, it is desirable in general to "mask" it or suppress type out. It appears that the server has no foolproof way to achieve this. It is therefore the responsibility of the user-FTP process to hide the sensitive password information.
Account (ACCT) - The argument field is an ASCII string identifying the user's account. The command is not necessarily related to the USER command, as some sites may require an account for login and others only for specific access, such as storing files. In the latter case the command may arrive at any time. There are two reply codes to differentiate these cases for the automaton: When account information is required for login and the server receives another command which he buffers, the legal response is reply code 331 when an account is required for a specific transfer requested, the reply code 433 is returned and the request command is flushed.
Reinitialize (REIN) - This command terminates a USER, flushing all I/O and account information, except to allow any transfer in progress to be completed. All parameters are reset to the default setting and the TELNET connection is left open. A USER command is expected to follow.
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. For "hot card-reader" mode the REIN command should be used instead.
An unexpected close on the TELNET connection will cause the server to take the effective action of an abort (ABOR) and a logout (BYE).
IV.A.2 Transfer Parameter 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 the last specified value, or if no value has been specified, the standard default value as stated 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. The default byte size is 8 bits. The byte size is always 8 bits in the ASCII and EBCDIC representation types. A server may reject specific byte size/type combinations by sending an error reply code in response to a transfer request command.
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).
Listen (LSTN) - The argument is a single ASCII character code to specify the direction of the socket that the server must allocate for use as a data connection. The server is to "listen" on the allocated socket when an appropriate transfer command is given. The following codes are assigned:
S - send
R - receive
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
E - EBCDIC
The default representation type is ASCII.
Format (FORM) - The argument is a single ASCII character code specifying the formats described in Section III.B. The following codes are assigned for format:
U - Unformatted
P - Printfile
The default format is Unformatted.
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 ecord structure)
R - Record structure
The default structure is File (ie. 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 code for EOR, EOF)
H - Hasp (specially formatted compressed data)
The default transfer mode is Stream.