[_includes/banner2.htm] [_includes/navigation.htm]
  Helpful Products
for technical FTP users
   

   
FTP Protocol Overview
Click here to email this page to a friend. A Brief description of File Transfer Protocol

File Transfer Protocol (FTP) requires two programs, a server program, and a client program. Normally the server program offer files to the client program. But in some cases, the server will also allow the client to upload files.

A simple FTP session
The client program connects to an FTP sever on the internet. Once connected, the FTP server sends a welcome message to the client over the open socket (network) connection.

Server: 220 Sample FTP server ready. Please give user-name 
Client
: USER anonymous 
Server
: 331 User name OK. Please give your email address as password 
Client
: PASS joe@nowhere.comm 
Server
: 230 User logged in

As you can see, the client and server are communicating in plain text. The digits in the server replies are 'reply-codes' defined by the FTP protocol. The uppercase words in the beginning of the client commands, are command verbs that also are defined by the RFC. The protocol is designed in a way that makes it easy for machines and humans to understand the dialog. In most cases, the client program doesn't have to interoperate the text after the reply code.

Now, the user wants to see the available files and directories, and issues a DIR command in the client program.

Client: TYPE A 
Server
: 200 Type set to A 
Client
: PASV 
Server
: 227 Entering passive mode (193,91,161,12,28,46) 
Client
: LIST 
Server
: 150 Opening ASCII mode data connection for /bin/ls 
Server
: 226 Transfer complete

The TYPE command tells the server to send the directory / file listing as plain ASCII, where each line is separated by a CRLF sequence.  The PASV command tells the server to prepare for a new socket connection by creating a new socket and then listening for a connection from the client.  Now, as you see, things are getting a little more complicated.  The server reply includes a IP address and a port number, encoded as 6 different number values, separated by commas.  The client must find and understand this address in order to receive the listing.

The LIST command tells the server to give a directory / file listing.  Now the server replies with two reply lines...  What's happening is that the first line tells the client that the listing is ready and that the client can go on and make a new connection to the server.  The client connects to the IP address given by the PASV reply and receives data until there is no more data to get. Then it closes the temporary data connection and switches back to the control connection to get the second reply line, which tells if the server transferred the whole listing.

In order to receive a directory listing, the client and server use two socket connections, one for the control flow (server sends commands, the server replies in plain text) and one for the data connection (which is continuous and goes in one direction only). Every time a directory-listing is sent, the server and client will use another new (temporary) socket connection for the transfer.

The user finds an interesting file, and gives the FTP client the command to get it.

Client: TYPE I 
Server
: 200 Type set to I 
Client
: PASV 
Server
: 227 Entering passive mode (193,91,161,12,28,46) 
Client
: RETR test.zip 
Server
: 150 Opening BINARY mode data connection for test.zip 
Server
: 226 Transfer complete

As you see, the server and client use the exact same method to get a file, as they do to get a directory listing.  The only change is that the RETR command is used in stead of the LIST command. In this case, the file was a .zip archive.  Since such files can't be translated to text-files (at least not in a safe manner), the FTP client switched to binary mode (TYPE I).  File and directory listings can be transferred in both binary and text-mode. Since different operating systems use different means to separate lines in text-files, it is generally a good idea to let the FTP server and FTP client do the conversion. Both know the rules for a ASCII (text) transfer and the client always knows the rules for the local storage of text-files.

You can connect to an FTP server with a Telnet client and give commands line by line.  However, it is much easier and safer to transfer files with an FTP client like WS_FTP Pro.

[_includes/bottom_nav.htm]