Miniscule FTP protocol

Flow of events

When the client connects with the server, the server sends back a welcoming message terminated by <CR><LF> (<CR> is ASCII 13, and <LF> is ASCII 10). The client should print this message to stdout.

The client and server now take turns exchanging messages, with the client making a request and the server sending a response.

Request/Response syntax

All requests and responses begin with three uppercase ASCII letters followed by a single ASCII space character. The three-letter code specifies the nature of the request or response. The rest of each request or response is dependent on the code.

Request/Response semantics

The possible request/response codes are as follows.
  1. LST To request a list of available files, the client sends the six characters "LST <CR><LF>". In response, the server first sends the "LST " code (including exactly one space character), followed immediately by a two-byte big-endian integer indicating the number of bytes in the listing. Note that this two-byte integer is not an ASCII representation of an integer, but rather a 16-bit unsigned binary integer. Finally, the server sends the listing itself.
  2. GET To request a file, the client send the "GET " code followed by the name of the requested file, followed by <CR><LF>. In response, the server sends the "FIL " code followed by a two-byte integer indicating the number of bytes in the file, followed by the file.
  3. BYE To close the connection, the client sends the six characters "BYE <CR><LF>". The server sends no reply.
  4. ERR If the server is unable to comply with the client's request, it sends back the "ERR " code followed by a three-uppercase-letter error type, followed by "<CR><LF>". At present, the only error types allowed are BFL (this "bad file" error occurs when the client asks for a file the server cannot or is unwilling to send) and HUH, which should be sent any other time the server can't figure out what to do.




Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057, (507) 646-4364, jondich@carleton.edu