Using the File Transfer Protocol
One of the oldest protocols still in use today is the File Transfer Protocol, known as FTP, which was first developed in 1971. It was designed to move files from one computer to another and to handle the translation problems that invariably occur when different types of computers try to communicate.
In order to access an FTP server, you must provide a user name and a password. This information is used to determine what level of access you will be granted.
Many FTP servers allow people to access the server by using “anonymous” as a user name and an e-mail address as the password. This permits people to access public information without having a predefined user name and password. (This was a popular technique for distributing information in the days prior to the World Wide Web.)
NOTE: Anonymous FTP: Most FTP servers that allow you to log on as anonymous ask you to send your e-mail address as your password. This allows the person responsible for the server to track usage at an individual level. While it may be tempting to use email@example.com as a password, you should be a responsible netizen (citizen of the Internet) and use your real e-mail address.
FTP Commands and Responses
To understand a protocol, I find it best to think of a series of commands and responses like you might see during a DOS session. For instance, in DOS, if you type a CD command followed by a path name, the computer processes your request and either returns an error or returns a command prompt. FTP works along these lines.
If you send a command to an FTP server, you will receive a three-digit response code describing how the server processed your command:
Codes that begin with 1 mean the command was successful, but you need to wait for another response code before issuing your next command.
Codes that begin with 2 describe the successful completion of a command.
Codes that begin with 3 mean that the server needs more information before it can complete the request.
Codes that begin with 4 mean that the system was too busy to process the command and that you should try again later.
- Codes that begin with 5 represent some kind of error; you should resolve the error before trying the command again.
FTP commands are grouped together as a session. You first must log on to the server. Then you can execute multiple commands to upload and download files, create and delete directories, and perform other tasks. When you are finished, you close the connection to the server. This will log you off the server. Note that you log on to the server only once, and the server remembers things like the current directory you are accessing.
FTP and URLs
A typical FTP URL might look like this:
This would download the file project1.exe in the /vb/inet directory on the ftp.justpc.com server. It would use wfreeze as the user name with a corresponding password of mypass.
Typically, when you use a URL with an FTP server, you will log on, execute a command, and log off again. This process will be repeated for each URL you execute. In some cases, such as when you want the user to download a single file, it’s okay to log off after executing the command. However, if you want a user to be able to create a directory and then upload multiple files, it is more efficient to use a regular FTP program rather than go through the logon and logoff process for each command executed.