C++
C++
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 C++ Downloads
#include <CkFtp2.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkFtp2 ftp;
ftp.put_Hostname("ftp.something.com");
ftp.put_Username("test");
ftp.put_Password("test");
// Connect and login to the FTP server.
success = ftp.Connect();
if (success != true) {
std::cout << ftp.lastErrorText() << "\r\n";
return;
}
// To use Passive mode:
ftp.put_Passive(true);
// or...
// To use Active mode:
ftp.put_Passive(false);
// ..
}