Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

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

loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
    destroy loo_Ftp
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Ftp.Hostname = "ftp.something.com"
loo_Ftp.Username = "test"
loo_Ftp.Password = "test"

// Connect and login to the FTP server.
li_Success = loo_Ftp.Connect()
if li_Success <> 1 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

// To use Passive mode:
loo_Ftp.Passive = 1

// or...
// To use Active mode:
loo_Ftp.Passive = 0

// ..


destroy loo_Ftp