Connecting through a proxy server |
The Ftp class allows for connections through SOCKS4 and SOCKS5 proxy servers. To use a proxy server set the ProxyHostname and ProxyPort properties.
Note
If your proxy requires authentication you can set this using the ProxyUsername and ProxyPassword properties.
Example
[C#]
// proxy information
String proxyHost = "10.0.0.1";
int proxyPort = 2121;
String proxyUsername = "jsmith";
String proxyPassword = "secret";
// create Ftp instance and set proxy information
Ftp myFtp = new Ftp(hostname,username,password);
myFtp.ProxyHost = proxyHost;
myFtp.ProxyPort = proxyPort;
myFtp.ProxyUsername = proxyUsername;
myFtp.ProxyPassword = proxyPassword;
// connect
myFtp.Connect();
[Visual Basic]
' proxy information
Dim proxyHost As String = "10.0.0.1"
Dim proxyPort As int = 2121
Dim proxyUsername As String = "jsmith"
Dim proxyPassword As String = "secret"
' create Ftp instance and set proxy information
Public WithEvents myFtp As Ftp = Nothing
Ftp myFtp = New Ftp(hostname,username,password)
myFtp.ProxyHost = proxyHost
myFtp.ProxyPort = proxyPort
myFtp.ProxyUsername = proxyUsername
myFtp.ProxyPassword = proxyPassword
' connect
myFtp.Connect()
See also
Connecting from behind a firewall