1

I am new to FTP protocol, here i have read about active and passive modes in ftp.

Active mode: means client will send port number to server for Data communication. Passive mode:means server will send port number to client for Data communication.

Here these and all okay

my doubt is in passive mode For initial control connection both will communicate on some port no example 5000 .After server receive "PASV" command server will send port number example 5010.

  1. After server sends port number to client, whether server should close port no 5000,and start listing on 5010 port? or both ports should be active?

  2. for Commands i need to use older port(5000) and for data communication i need to use new port(5010), or how it is?

Can anyone help me this

3
  • 1
    Both. The server is a multi-thread process. When it sends out the port number to the client, it creates a new thread (it "forks") that will listen on that port, but the server process will keep listening on the main port for commands from other clients. – Jos Sep 15 '20 at 8:44
  • 1
    what about commands and data communication, in which port commands communication happens means old port or new port – Srihari Sep 15 '20 at 9:42
  • 2
    This is all explained here. – Jos Sep 15 '20 at 10:14
1

FTP protocol differs from simpler protocols like ssh or HTTP in that it uses two ports (and two connections) simultaneously.

The port you initially connect to is the command port. The connection to this port is active until the session is terminated and all commands are sent to this port.

When you issue commands that start data transfer - like get or put - another connection (called data connection) is established on another port (data port). This connection is from server to client in active mode and from client to server in passive mode. This connection lasts only for the duration of the data transfer and it is closed after the transfer is finished.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.