Sample code for 30+ languages & platforms
Delphi DLL

Active and Passive Modes in FTP

See more FTP Examples

The Passive property controls whether data connections for uploads/downloads are established in Active or Passive mode. To use Active mode, set the Passive property = _FALSE_. This is the default. To use Passive mode, set the Passive property = _TRUE_.

About Passive/Active Modes:

Active Mode:
The FTP client chooses a port number and sends a “PORT” command to the FTP server. The FTP client then listens at the chosen port and the FTP server issues a connect request to establish the connection. The data connection is outgoing from the FTP server, and incoming to the FTP client.

Passive Mode:
The FTP client sends a PASV command to the FTP server. The FTP server chooses a port number and sends it in the PASV response. The FTP server then listens at that port for the incoming connect request from the FTP client. The data connection is incoming to the FTP server, and outgoing from the FTP client.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Ftp2;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
ftp: HCkFtp2;

begin
success := False;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

ftp := CkFtp2_Create();

CkFtp2_putHostname(ftp,'ftp.something.com');
CkFtp2_putUsername(ftp,'test');
CkFtp2_putPassword(ftp,'test');

// Connect and login to the FTP server.
success := CkFtp2_Connect(ftp);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkFtp2__lastErrorText(ftp));
    Exit;
  end;

// To use Passive mode:
CkFtp2_putPassive(ftp,True);

// or...
// To use Active mode:
CkFtp2_putPassive(ftp,False);

// ..

CkFtp2_Dispose(ftp);

end;