File Transfer Protocol (FTP) – Computer Networks

file transfer protocol ftp

After covering the Hyper Text Transfer protocol, now we are going to have a look at the another Application Layer protocol i.e. File Transfer Protocol.

In a File Transfer, the user or the local host wants to transfer files from remote file system to the local file system and vice versa. In order to access the remote account, the user has to authenticate himself by providing a username and a password. After filling this authentication information , the user can transfer files to or from the remote host.

The user or the host interacts with the FTP server with a FTP client or user-agent. The user provides the hostname of the remote server, that causes the FTP client process in the local host to establish a TCP connection with the FTP server process in the remote host.

******** For HTTP user, Browser acts as a client. Therefore for FTP , you need to install a FTP client or a user-agent that can interact with the server. *********

The user then provides the username and the password that are sent over the TCP connection as FTP commands. After the server authorises the user, the user can copy files from local file system to the remote file system and vice versa.

Difference Between HTTP & FTP

hypertext transfer protocol http

Hyper Text Transfer protocol and File Transfer protocol both are for the transfer of files from one host to other. There are many common characteristics among them. For example, FTP and HTTP both run over TCP.

But there are many differences between them. So we will discuss the differences.

i) FORMAT : HTTP only uses Binary Format whereas FTP can data both in ASCII and Binary Format.

ii) META-DATA :  HTTP headers contains metadata such as last modified date, server name, version and many more but these all are absent in FTP.

iii) CONNECTIONS : While HTTP have a persistent connection and can transfer as many files on a single TCP connection. In FTP a different connection has to be made for every individual file transfer.

iv) SPEED : There are various parameters on which the speed of HTTP or FTP is justified.

Ques 1 : Why FTP is faster ?
As there is no meta-data in FTP, so FTP is faster.


Ques 2 : Why HTTP is faster?

There is a persistent connection in HTTP, so it is faster.

v) USER-AGENTS or CLIENTS: In HTTP, browser is the client, In FTP , your command prompt can act as a client.


vi) Now the most important difference between a HTTP and FTP is that HTTP uses a single TCP connection to request and transfer files. On the other hand, FTP uses two parallel connections to transfer a file. These connection are known as Control Connection and Data Connection.

  • The information such as username, passwords, commands to ‘put’ or ‘get’ files are sent by Control Connection.
  • The actual files are sent over Data Connection.

 Because of this property of FTP , it is known as out-of-band protocol. As it uses a separate control connection to send the control information. You must remember that HTTP uses the same TCP connection to send request and receive response. Therefore HTTP is said to be as In-Band Protocol.

File transfer protocol FTP data Connection

Working between FTP Client And FTP Server:


The FTP client initiates a control TCP connection with the server on port number 21 , before a user starts an FTP session with the remote host. The user sends its username and password over this control connection. When the server receives a request ( in the form of FTP command) for a file transfer over the control connection, the remote host initiates a TCP data connection to the client. Only one file is sent over a data connection and then the data connection is closed. If, during the same session, the client wants to transfer one more file, then FTP opens another data connection. This implies that, the control connection remains open for the whole session in FTP, but always a new data connection is generated for transfer of every new file. That means, data connection is non-persistent.


Also, FTP maintains a state information of the client. Therefore, if the client transfers the same file during the same session, the remote host will warn it and will not allow it. Thus, FTP is said to be as the STATEFUL Protocol. On the other hand , HTTP is a Stateless Protocol – doesn’t maintain any state of the client.




FTP control connection



 As request and response commands in HTTP were there. Similarly there are FTP commands.

User Commands:

These commands are request from client to server. These are in 7-bit ASCII format. Thus, they are easily read by a human being. Some of the FTP commands are:

i) USER username : It is used to send the username to the server.

ii) PASS password : It is used to send the password to the server.

iii) RETR filename : It is used to retrieve or to get the file from the server. This command causes the remote host to initiate a data connection.

iv) STOR filename : It is used to store a file on to the server.

v) LIST : It is used to ask the server to send back all the files in the current directory. The list of files is sent over a new data connection, but not over the control connection.

Server or Remote Host Commands :


These are the responses from the server to the client request. These are also 7-bit ASCII format.

i) 331 Username OK, password required

ii) 125 : Data Connection already open. Start transfer of files.

iii) 425 : Error opening data connection

iv) 452 : File cannot be write or Error Writing file

******* If you are really interested to know more about FTP, I would ask you to read RFC 959 in order to get a deep knowledge of the FTP commands and replies.

Thank you for reading this article. We hope you enjoyed it.

This is all from us on File Transfer Protocol. Do you have some information to share with our readers ?

Raman Deep Singh Chawla

Raman Deep Singh Chawla

Raman is the founder of FitnyTech . He is a fitness App Developer and a Blogger. He is fond of his fitness and sports. He has great passion for Cricket , Tennis , Soccer and Table Tennis. In his free time , he loves to learn about technology , write about it , share his thoughts with others. His passion for technology can be seen at his blogs.

More Posts

Leave a Reply

Your email address will not be published. Required fields are marked *