Connecting from behind a firewall

Top  Previous  Next

The Ftp class is firewall friendly in that by default it uses a firewall friendly passive connection. Some firewalls however may require that you route all connections through the firewall. To do this you must change the arguments passed to the Ftp constructor.

 

Example

 

The example below routes the FTP connection through the firewall.

 

[C#]

// define connection setting

int firewallPort = 21;

String firewallHostname = "192.168.1.1";

String ftpHostname = "ftp.myhost.com";

String ftpUsername = "jsmith";

String ftpPassword = "secret";

 

// create new Ftp instance

Ftp myFtp = new Ftp(firewallHostname, ftpUsername + "@" + ftpHostname, ftpPassword, firewallPort);

 

// establish connection thru firewall

myFtp.Connect();

 

 

[Visual Basic]

' define connection setting

Dim firewallPort As int = 21

Dim firewallHostname As String = "192.168.1.1"

Dim ftpHostname As String = "ftp.myhost.com"

Dim ftpUsername As String = "jsmith"

Dim ftpPassword As String = "secret"

 

' create new Ftp instance

Public WithEvents myFtp As Ftp = Nothing

Ftp myFtp = New Ftp(firewallHostname, ftpUsername + "@" + ftpHostname, ftpPassword, firewallPort)

 

' establish connection thru firewall

myFtp.Connect()

 

 

See also

 

Connecting through a proxy server