What's the difference between active and passive mode in FTP?

asked 18 Oct '10, 13:58

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519
accept rate: 63%

edited 22 Mar, 17:19


FTP uses two communication channels: control connections and data connection.

Control connection

  • clients connects to server's port 21
  • remains open for the duration of the session
  • used for sending commands such as change directory, login etc.

Data connection

  • new connection is opened and closed for each data transfer
  • used for upload, download and directory listing

Active and Passive mode

Active and passive mode determines how the data connection is opened.

Passive mode

In active mode FTP server connects to the client. This used to be default mode in the past, however, this is not very firewall friendly.

Typical communication goes as follows:

Client: PORT 192,168,1,2,251,248
Server: 200 PORT command successful.
Client: RETR readme.txt
Server: 150 Opening BINARY mode data connection for /readme.tx(1884 bytes).
Server: 226 Transfer complete.

Passive mode

In passive mode FTP client connects to the server. This is default when connecting to the FTP server from a web browser.

Typical communication goes as follows:

Client: PASV
Server: 227 Entering Passive Mode (192,168,1,1,9,87).
Client: RETR readme.txt
Server: 125 Data connection already open; Transfer starting.
Server: 226 Transfer complete.

Active and Passive mode in Rebex FTP

Following code enables active mode in Rebex FTP:

Ftp ftp = new Ftp();
ftp.Passive = false;

Following code enables passive mode in Rebex FTP:

Ftp ftp = new Ftp();
ftp.Passive = true; // this is default
link

answered 19 Oct '10, 15:52

Martin%20Vobr's gravatar image

Martin Vobr ♦♦
335310
accept rate: 37%

edited 19 Oct '10, 16:02

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×152
×15
×5
×4

Asked: 18 Oct '10, 13:58

Seen: 1,091 times

Last updated: 22 Mar, 17:19