RFC 640
Revised FTP reply codes
Revised FTP Reply Codes ๐
RFC 640 ๐
Jon Postel, 19 JUN 75 ๐ธ
Bestie, this doc is by Nancy Neigus, Ken Pogran, and Jon Postel (the authors' names are listed at the top and again at the end of the first part). It's dated 19 JUN 75. The header doesn't list a category or status, and it doesn't say it obsoletes anything. What it does say is that it modifies the protocol described in RFC 542 โจ. So the protocol on socket number 21 (decimal) is the combination of RFC 542 and this RFC ๐ง.
This document is all about a revised set of reply codes for the File Transfer Protocol ๐ฆ.
The goal here is pretty iconic. We want reply codes that let the command-issuing process easily figure out how each command turned out ๐ . The user protocol interpreter should be able to tell whether a command succeeded or failed just by looking at the first digit of the reply code ๐ฅ.
Okay, here's a big change to the order of commands and replies that you might not catch in the later docs. It has to do with how the data connection gets set up ๐.
In the older FTP specs, when an actual transfer command (STOR, RETR, APPE, LIST, NLIST, MLFL) was issued, the preliminary reply got sent after the data connection was established. That was a problem for some user protocol interpreters because it was hard for them to watch two connections at the same time asynchronously ๐ญ.
The current spec says the preliminary reply to the actual transfer commands tells you that the file can be transferred, and that either the connection was already set up or an attempt is about to be made to set it up ๐.
This reply code revision is a modification of the protocol described in RFC 542. That means the protocol implementation on socket number 21 (decimal) is the one specified by RFC 542 and this RFC together ๐.
Huge thanks to everyone who helped with this work: Ken Pogran, Mark Krilanovich, Wayne Hathway, and especially Nancy Neigus ๐ซถ.
Nancy Neigus, Ken Pogran, Jon Postel, 19 JUN 75 ๐
A New Schema for FTP Reply Codes โจ
Replies to File Transfer Protocol commands exist to keep requests and actions in sync during a file transfer, and to make sure the user process always knows the state of the Server ๐ง . Every command has to generate at least one reply, though it can produce more than one. When it does, those multiple replies must be easy to tell apart ๐ . Some commands also come in sequential groups, like USER, PASS and ACCT, or RNFR and RNTO. The replies show an intermediate state exists when every command before it has succeeded. If something fails partway through, the whole sequence has to be repeated from the beginning ๐ญ.
Details of the command-reply sequence will be made explicit in a state diagram ๐บ๏ธ.
An FTP reply is a three digit number (sent as three alphanumeric characters) followed by some text ๐. The number is for automata to decide what state to go into next. The text is for the human user ๐. The three digits are supposed to carry enough encoded info that the user-process (the User-PI described in RFC 542) doesn't need to read the text at all. It can throw the text away or pass it along to the user, whichever makes sense โจ. The text might depend on the server, so you'll probably see different text for each reply code ๐ซ.
Formally, a reply is the 3-digit code, then a space, <SP>, then one line of text (with some maximum line length specified), ending with the TELNET end-of-line code <eol>. Sometimes the text runs longer than one line ๐. In that case the whole text has to be bracketed so the User-process knows when to stop reading the reply (aka stop processing input on the TELNET connection) and go do other stuff ๐โโ๏ธ. That means the first line needs a special format to say more lines are coming, and the last line needs another format to say it's the last one ๐. At least one of those lines must contain the right reply code so people know the state of the transaction ๐ฅ. To keep everyone happy, the first and last line codes are both the same ๐.
So the multi-line format is this: the first line starts with the exact reply code, immediately followed by a Hyphen, "-" (also known as Minus), and then the text. The last line starts with the same code, immediately followed by a Space <SP>, then optionally some text, then TELNET <eol> ๐ธ.
For example:
123-First line
Second line
234 A line beginning with numbers
123 The last line
The user-process only has to look for the second occurrence of the same reply code, followed by <SP>, at the start of a line, and ignore everything in between ๐ง. If a middle line starts with a 3-digit number, the Server has to pad the front of it so nothing gets confused ๐ก๏ธ.
This setup lets standard system routines handle reply info (like for the STAT reply), with "artificial" first and last lines tacked on ๐งฉ. In the rare cases where those routines can produce three digits and a Space at the start of any line, each text line should be offset by some neutral text, like a Space ๐ซง.
This scheme assumes multi-line replies can't be nested ๐ โโ๏ธ. In general, nesting doesn't happen, except for random system messages (called spontaneous replies in earlier FTP versions) that can interrupt another reply ๐ณ. Spontaneous replies aren't defined anymore. System messages (the ones the FTP server doesn't process) will NOT carry reply codes, and they can show up anywhere in the command-reply sequence ๐. The User-process can ignore them, since they're only info for the human user ๐ .
The three digits of a reply each mean something specific ๐ข. This lets things range from super simple to super sophisticated on the user-process side โจ. The first digit says whether the response is good, bad, or incomplete ๐ฏ. (Check the state diagram.) An unsophisticated user-process can decide its next move (keep going as planned, redo, back off, etc.) by just looking at that first digit ๐ฏ. A user-process that wants to know roughly what kind of error happened (like a file system error or a command syntax error) can look at the second digit. The third digit is kept for the finest level of detail, like an RNTO command with no RNFR before it ๐.
There are four possible values for the first digit of the reply code ๐:
1yzPositive Preliminary reply ๐ฆ
The requested action is starting up. Expect another reply before moving on to a new command. (If the user-process sends another command before the completion reply, that breaks protocol. Server-FTP processes should queue any commands that arrive while a previous command is still running.) This type of reply can tell the user-process that the command was accepted and it can now watch the data connections, for implementations where watching both at once is hard ๐.
2yzPositive Completion reply ๐
The requested action finished successfully. A new request can be started ๐.
3yzPositive Intermediate reply ๐
The command was accepted, but the requested action is on hold until more info arrives. The user should send another command giving that info. This reply is used in command sequence groups ๐.
4yzTransient Negative Completion reply โณ
The command wasn't accepted and the requested action didn't happen, but the error is temporary and the action can be requested again. The user should go back to the start of the command sequence, if there is one ๐. "Transient" is kind of a slippery word, especially when two separate sites (Server and User-processes) have to agree on what it means. Each reply in the 4yz category might have a slightly different time value, but the point is that the user-process is encouraged to try again ๐ช. Here's a rule of thumb for whether a reply is 4yz or 5yz (Permanent Negative): it's 4yz if the command can be repeated without changing the command form or the properties of the User or Server. For example, the command is spelled the same with the same arguments, the user doesn't change their file access or user name, and the server doesn't get a new implementation ๐ง.
5yzPermanent Negative Completion reply ๐ซ
The command wasn't accepted and the requested action didn't happen. The User-process is discouraged from repeating the exact same request (in the same sequence) ๐ . Even some "permanent" errors can be fixed, so the human user might want to tell their User-process to restart the command sequence later on, after something like a spelling fix or a change to their directory status ๐ ๏ธ.
The second digit groups replies by function ๐๏ธ:
x0zSyntax ๐ป
These replies are about syntax errors, syntactically correct commands that don't fit any functional category, and unimplemented or superfluous commands ๐งพ.
x1zInformation ๐
These are replies to requests for information, like status or help ๐โโ๏ธ.
To be continued... ๐โจ
The second digit tells you the function group, and the third digit narrows it down, so these replies work like a little family tree ๐ณโจ
x2z Connections - Replies referring to the TELNET and
data connections.
x3z Authentication and accounting - Replies for the logon
process and accounting procedures.
x4z Unspecified as yet
x5z File system - These replies indicate the status of
the Server file system vis-a-vis the requested
transfer or other file system action.
Okay so the third digit gives you a finer vibe within each function category that the second digit sets up ๐ The list below shows it off. The text attached to each reply is only suggestive, not mandatory, and it can even shift depending on which command it's answering ๐ฆ The reply codes, though? Those are strict. Server implementations should not invent brand-new codes for situations that are only slightly different from the ones described here. They should adapt the codes that already exist instead ๐ซถ
If you really do need more codes, send the details to the FTP committee, through Jon Postel ๐ฎ
A command like TYPE or ALLO, where running it successfully doesn't give the user-process any new information, gets a 200 reply ๐ธ If a Server-FTP process doesn't implement the command because it has no relevance on that computer system (ALLO at a TENEX site, for example), a Positive Completion reply is still wanted, so the simple User-process knows it can keep going ๐ For that case you use 202, with reply text like "No storage allocation necessary." ๐ง If the command asks for something that isn't site-specific and it's unimplemented, the response is 502 ๐ And 504 is the refinement for a command that IS implemented but asks for a parameter that isn't ๐
200 Command okay
500 Syntax error, command unrecognized
[This may include errors such as command line too
long.]
501 Syntax error in parameters or arguments
202 Command not imlemented, superfluous at this site.
502 Command not implemented
503 Bad sequence of commands
504 Command not implemented for that parameter
Now the 110 reply, which is the main one with strict text ๐ฅ The text here is exact and not left up to the implementation, so it has to read:
MARK yyyy = mmmm
Here yyyy is the User-process data stream marker, and mmmm is the Server's equivalent marker. (Note the spaces between the markers and "=".) ๐
110 Restart marker reply.
211 System status, or system help reply
212 Directory status
213 File status
214 Help message (on how to use the server or the meaning
of a particular non-standard command. This reply
is useful only to the human user.)
120 Service ready in nnn minutes
220 Service ready for new user
221 Service closing TELNET connection (logged off if
appropriate)
421 Service not available, closing TELNET connection.
[This may be a reply to any command if the service
knows it must shut down.]
125 Data connection already open; transfer starting
225 Data connection open; no transfer in progress
425 Can't open data connection
226 Closing data connection; requested file action
successful (for example, file transfer or file
abort.)
426 Connection trouble, closed; transfer aborted.
227 Entering [passive, active] mode
230 User logged on, proceed
530 Not logged in
331 User name okay, need password
332 Need account for login
532 Need account for storing files
150 File status okay; about to open data connection.
250 Requested file action okay, completed.
350 Requested file action pending further information
450 Requested file action not taken: file unavailable
(e.g. file not found, no access)
550 Requested action not taken: file unavailable (e.g.
file busy)
451 Requested action aborted: local error in processing
452 Requested action not taken: insufficient storage
space in system
552 Requested file action aborted: exceeded storage
allocation (for current directory or dataset)
553 Requested action not taken: file name not allowed
354 Start mail input; end with <CR><LF>.<CR><LF>
Command-Reply Sequences โจ
Okay, this part is the sequence playbook ๐ Each command shows up with its possible replies, and commands in the same group are listed together ๐ Preliminary replies come first (with their follow-up replies tucked under them), then positive and negative completion, and finally the intermediary replies plus whatever's left of the sequence. This listing is the basis for the state diagrams, which get presented separately ๐ฆ
ICP
120
220
220
421
Logon
USER
230
530
500, 501, 421
331, 332
PASS
230
202
530
500, 501, 503, 421
332
ACCT
230
202
530
500, 501, 503, 421
Logoff
QUIT
221
500
REIN
120
220
220
421
500, 502
Transfer parameters
SOCK
200
500, 501, 421, 530
PASV
227
500, 501, 502, 421, 530
ACTV
227
202
500, 501, 421, 530
BYTE, MODE, TYPE, STRU
200
500, 501, 504, 421, 530
File action commands
ALLO 13e1
200 13e1a
202 13e1b
500, 501, 504, 421, 530 13e1c
REST 13e2
500, 501, 502, 421, 530 13e2a
350 13e2b
STOR 13e3
125, 150 13e3a
(110) 13e3a1
226, 250 13e3a2
425, 426, 451, 552 13e3a3
532, 450, 452, 553 13e3b
500, 501, 421, 530 13e3c
RETR 13e4
125, 150 13e4a
(110) 13e4a1
226, 250 13e4a2
425, 426, 451 13e4a3
450, 550 13e4b
500, 501, 421, 530 13e4c
LIST, NLST 13e5
125, 150 13e5a
226, 250 13e5a1
425, 426, 451 13e5a2
450 13e5b
500, 501, 502, 421, 530 13e5c
APPE 13e6
125, 150 13e6a
(110) 13e6a1
226, 250 13e6a2
425, 426, 451, 552 13e6a3
532, 450, 550, 452, 553 13e6b
500, 501, 502, 421, 530 13e6c
MLFL 13e7
125, 150 13e7a
226, 250 13e7a1
425, 426, 451, 552 13e7a2
532, 450, 550, 452, 553 13e7b
500, 501, 502, 421, 530 13e7c
RNFR 13e8
450, 550 13e8a
500, 501, 502, 421, 530 13e8b
350 13e8c
RNTO 13e9
250 13e9a
532, 553 13e9b
500, 501, 502, 503, 421, 530 13e9c
DELE 13e10
250 13e10a
450, 550 13e10b
500, 501, 502, 421, 530 13e10c
ABOR 13e11
225, 226 13e11a
500, 501, 502, 421 13e11b
MAIL 13e12
354 13e12a
250 13e12a1
451, 552 13e12a2
450, 550, 452, 553 13e12b
500, 501, 502, 421, 530 13e12c
Informational commands 13f
STAT 13f1
211, 212, 213 13f1a
450 13f1b
500, 501, 502, 421, 530 13f1c
HELP 13f2
211, 214 13f2a
500, 501, 502, 421 13f2b
Miscellaneous commands 13g
SITE 13g1
200 13g1a
202 13g1b
500, 501, 530 13g1c
NOOP 13g2
200 13g2a
500 13g2b
Jon Postel
19 JUN 75
FTP State Diagrams โจ 14
Okay so here are the state diagrams for a super simple-minded FTP implementation ๐ง Only the first digit of the reply codes gets looked at, and there's one diagram for each group of FTP commands or command sequences ๐ 15
The groups were made by building a model for each command, then bundling together the commands with structurally identical models ๐ 16
For every command or command sequence there are three possible outcomes: success (S), failure (F), and error (E). In the diagrams below, B means "begin" and W means "wait for reply" ๐ 17
First up is the diagram for the biggest group of FTP commands ๐ 18
1,3 +---+
----------->! E !
! +---+
!
+---+ cmd +---+ 2 +---+
! B !---------->! W !---------->! S !
+---+ +---+ +---+
!
! 4,5 +---+
----------->! F !
+---+
18a
This diagram models the commands: 18b
ABOR, ACTV, ALLO, BYTE, DELE, HELP, MODE, NOOP, PASV, QUIT,
SITE, SOCK, STAT, STRU, TYPE. 18b1
The other big group is shown by a very similar diagram ๐ฆ 19
3 +---+
----------->! E !
! +---+
!
+---+ cmd +---+ 2 +---+
! B !---------->! W !---------->! S !
+---+ --->+---+ +---+
! ! !
! ! ! 4,5 +---+
! 1 ! ----------->! F !
----- +---+
19a
This diagram models the commands: 19b
APPE, (ICP), LIST, MLFL, NLST, REIN, RETR, STOR. 19b1
Ngl, this second model could also be used for the first group ๐ The only difference is that in the first group, the 100 series replies are unexpected and get treated as errors, while the second group expects (some may require) 100 series replies 20
The rest of the diagrams model command sequences. The simplest one is the rename sequence ๐ธ 21
+---+ RNFR +---+ 1,2 +---+
! B !---------->! W !---------->! E !
+---+ +---+ -->+---+
! ! !
3 ! ! 4,5 !
-------------- ------ !
! ! ! +---+
! ------------->! S !
! ! 1,3 ! ! +---+
! 2! --------
! ! ! !
V ! ! !
+---+ RNTO +---+ 4,5 ----->+---+
! !---------->! W !---------->! F !
+---+ +---+ +---+
21a
A very similar diagram models the Mail command ๐ 22
+---+ MAIL +---+ 1,2 +---+
! B !---------->! W !---------->! E !
+---+ +---+ -->+---+
! ! !
3 ! ! 4,5 !
-------------- ------ !
! ! ! +---+
! ------------->! S !
! ! 1,3 ! ! +---+
! 2! --------
! ! ! !
V ! ! !
+---+ text +---+ 4,5 ----->+---+
! !---------->! W !---------->! F !
+---+ +---+ +---+
22a
Note that the "text" here is a series of lines sent from the user to the server, with no response expected until the last line is sent. Remember, the last line must consist only of a single period. 22b
The next one is a simple model of the Restart command โจ 23
+---+ REST +---+ 1,2 +---+
! B !---------->! W !---------->! E !
+---+ +---+ -->+---+
! ! !
3 ! ! 4,5 !
-------------- ------ !
! ! ! +---+
! ------------->! S !
! ! 3 ! ! +---+
! 2! --------
! ! ! !
V ! ! !
+---+ cmd +---+ 4,5 ----->+---+
! !---------->! W !---------->! F !
+---+ -->+---+ +---+
! !
! 1 !
------
23a
Where "cmd" is APPE, STOR, RETR, or MLFL. 23a1
We noticed the above three models are giving a whole family resemblance ๐ฏ, because the Mail diagram and the Rename diagram are structurally identical ๐ The Restart is only different from the other two in how it treats 100 series replies at the second stage ๐ 24
The most complicated diagram is for the Logon sequence, and it is lowkey spaghetti ๐ 25
1
+---+ USER +---+------------->+---+
! B !---------->! W ! 2 ---->! E !
+---+ +---+------ ! -->+---+
! ! ! ! !
3 ! ! 4,5 ! ! !
-------------- ----- ! ! !
! ! ! ! !
! ! ! ! !
! --------- !
! 1! ! ! !
V ! ! ! !
+---+ PASS +---+ 2 ! ------>+---+
! !---------->! W !------------->! S !
+---+ +---+ ---------->+---+
! ! ! ! !
3 ! !4,5! ! !
-------------- -------- !
! ! ! ! !
! ! ! ! !
! -----------
! 1,3! ! ! !
V ! 2! ! !
+---+ ACCT +---+-- ! ----->+---+
! !---------->! W ! 4,5 -------->! F !
+---+ +---+------------->+---+
25a
Finally, we present a generalized diagram that could be used to model the command and reply interchange, and honestly it's the blueprint for the whole vibe ๐ฆ 26
------------------------------------
! !
Begin ! !
! V !
! +---+ cmd +---+ 2 +---+ !
-->! !------->! !---------->! ! !
! ! ! W ! ! S !-----!
-->! ! -->! !----- ! ! !
! +---+ ! +---+ 4,5 ! +---+ !
! ! ! ! ! ! !
! ! ! 1! !3 ! +---+ !
! ! ! ! ! ! ! ! !
! ! ---- ! ---->! F !-----
! ! ! ! !
! ! ! +---+
-------------------
!
!
V
End
๐ฆ where this page comes from
- ietf: rfc640 1974-06
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms