V. Declarative Specifications
In order to make FTP workable without needless error messages, the following minimum implementation is required for servers:
TYPE -- ASCII (with 8-bit bytes)
MODE -- Stream
STRUCTURE -- File
Record (with ASCII type and CRLF for EOR)
FORM -- Unformatted
COMMANDS -- USER, BYE, SOCK
TYPE, BYTE, MODE, STRU, FORM
for the default values
RETR, STOR
NOOP
The initial default values for transfer parameters are:
TYPE -- ASCII
BYTE -- 8
MODE -- Stream
STRU -- File
FORM -- Unformatted
V.A Connections
The server-FTP process at the server site shall "listen" on Socket 3, via its server-TELNET. The user or user-FTP process at the user site shall initiate the full-duplex TELNET connections via its user-TELNET performing the ARPANET standard initial connection protocol (ICP) to server socket 3. Servers may specify that interaction over the TELNET connections be line-at-a-time with local echo. The server is not obliged to provide remote echo and may ignore TELNET control characters; he should not, however, return error response to the latter. All editing of command lines similarly must be local. The TELNET connections shall be closed by the user site upon completion of use and receipt of the last server reply.
The user site must "listen" on the specified data socket or sockets (a send and/or a receive socket). The server site shall initiate the data connection using the specified data socket and byte size. The direction of data connection and the data socket used shall be determined by the FTP service command. The server shall send a reply to the user indicating the server data socket so that the user may ensue the security of data transfer. This can be done at any time prior to the first transfer of data over a data connection. It should be emphasized that the user-FTP should not wait for a 255 (server data socket) reply before doing the "listen", since there is no guarantee that the reply will arrive before the user site receives the initiating RFC. The security check can be done when the reply arrives and the data connection closed if it was made to a socket other than the one specified.
The data connection shall be closed by the server site under the conditions described in Section III.A. If the server wishes to close the connection in modes where that is not required, it is recommended that the close be sent immediately after the file transfer is completed rather than after a new transfer command is received, because the user or server may have to test the state of the socket before doing a "listen" or "init". The server should in general send a reply before closing the data connection to avoid problems at the user end, though, for reasons stated above, the user-FTP should not wait for the reply before doing his close.
V.B Commands
The commands are ASCII character strings transmitted over the TELNET connections as described in section IV.A. The command functions and semantics are described in sections IV.A.1, IV.A.2, IV.A.3, and IV.A.4. The command syntax is specified here.
The commands begin with a command code followed by an argument field. The command codes are four or less ASCII alphabetic characters. Upper and lower case alphabetic characters are to be treated identically. Thus any of the following may represent the retrieve command:
RETR Retr retr ReTr rETr
This also applies to any symbols representing parameters values, such as A or a for ASCII TYPE. The command codes and the argument fields are separated by one or more spaces.
The argument field consists of a variable length ASCII character string ending with the character sequence CRLF (Carriage Return immediately followed by Line Feed). In the following section on syntax it should be stressed that all characters in the argument field are ASCII characters. Thus a decimal integer shall mean an ASCII represented decimal integer.
The following are all the currently defined FTP commands:
USER <username> CRLF
PASS <password> CRLF
ACCT <acctno> CRLF
REIN CRLF
BYE CRLF
BYTE <byte size> CRLF
SOCK <HOST-socket> CRLF
LSTN <direction> CRLF
TYPE <type code> CRLF
FORM <form code> CRLF
STRU <structure code> CRLF
MODE <mode code> CRLF
RETR <pathname> CRLF
STOR <pathname> CRLF
APPE <pathname> CRLF
ALLO <decimal integer> CRLF
REST <marker> CRLF
RNFR <pathname> CRLF
RNTO <pathname> CRLF
ABOR CRLF
DELE <pathname> CRLF
LIST <pathname> CRLF
NLST <pathname> CRLF
STAT <pathname> CRLF
HELP <string> CRLF
MLFL <users> CRLF
MAIL <users> CRLF
NOOP CRLF
QUOT CRLF
NQUO CRLF
The syntax of the above argument fields (using BNF notation where applicable) is:
<username> ::= <string>
<password> ::= <string>
<acctno> ::= <string>
<string> ::= <empty>/<char>/<char><string>
<char> ::= any of the 128 ASCII characters except CR and LF.
<marker> ::= <pr string>
<pr string> ::= <empty>/<pr char>/<pr char> <pr string>
<pr char> ::= any ASCII code 33 through 126
<byte size> ::= any decimal integer 1 through 255.
<HOST-socket> ::= <socket>/HOST number>,<socket>
<HOST number> ::= a decimal integer specifying an ARPANET HOST
<socket> ::= decimal integer between 0 and (2**32)-1
<direction> ::= S/R
<form code> ::= U/P
<type code> ::= A/E/I/L
<structure code> ::= F/R
<mode code> ::= S/B/T/H
<pathname> ::= <string>
<decimal integer> ::= <digit>/<digit><decimal integer>
<digit> ::= 0|1|2|3|4|5|6|7|8|9
<empty> ::= the null string (specifies use the default).
<users> ::= <user>|<user,<users>
<user> ::= <empty>|<NIC ident>|<sys ident>
<NIC ident> ::= <string>
<sys ident> ::= <string>