In this two part series about FTP we are going to look at what an FTP server is and what it is used for. The first part will cover the theory and the second part will put all the theory into practice; it's where we will actually implement an FTP server. I'm doing the theory first to give you a bit of background about the FTP protocol. This will make it easy for you to understand the purpose of each command in the protocol as well as how to implement them in the next article.
Delphi 7 and higher, Indy10.1.15 or higher and lots and lots of enthusiasm.
What is an FTP Server?
An FTP server handles the process of transferring files from one computer to another. The FTP protocol defines how FTP programs should work together when sharing files. It uses the client/server model in its implementation. This means that in order to use an FTP server, you will need an FTP client. In most cases the FTP server program offers files to the client program, but it also makes provision for the client to upload files.
As with all protocols that uses the client server model, the process of sending and receiving files is done through the request/response method and involves commands. The client usually makes the request and the server responds. In order for a client to connect to a server, the FTP server application needs to be active and listening on a port. An FTP server usually runs on port number 21.
When an FTP client connects to an FTP server it uses a username and password to help make the process secure. There is also an option to enable anonymous access to an FTP server, where an FTP client does not need a valid username or password. The communication between the FTP client and the FTP server is in plain text and uses reply codes as defined by the FTP protocol. Here’s an example communication between an FTP client and FTP server:
Server: 220 Welcome to my Indy FTP Server ready.
Client: user myusername
Server: 331 User name okay, need password.
Client: pass mypassword
Server: 230 User logged in, proceed.
Client: Help
Server: 500 'Help': command not understood.
Client: Help
214-The following commands are recognized (* => unimplemented, + => extension).