Classic ASP
Classic ASP
Connect to FTP Through a SOCKS Proxy
See more FTP Examples
Demonstrates connecting through a SOCKS proxy using SocksVersion, SocksHostname, SocksPort, SocksUsername, and SocksPassword.
Background: SOCKS is a general-purpose TCP relay, so it carries FTP transparently.
SocksVersion is the switch — 0 disables it, while 4 or 5 selects the protocol. SOCKS5 supports username/password authentication and is the usual choice; SOCKS4 supports only a user identifier. Because FTP opens separate data connections, a SOCKS proxy combined with passive mode is generally the most reliable arrangement.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
set ftp = Server.CreateObject("Chilkat.Ftp2")
ftp.Hostname = "ftp.example.com"
ftp.Username = "myFtpLogin"
' SocksVersion selects the proxy: 0 (default) = none, 4 = SOCKS4, 5 = SOCKS5.
ftp.SocksVersion = 5
ftp.SocksHostname = "socks.example.com"
ftp.SocksPort = 1080
' SOCKS5 supports username/password authentication; SOCKS4 uses only a user identifier.
ftp.SocksUsername = "myProxyLogin"
ftp.SocksPassword = "myProxyPassword"
' Normally you would not hard-code the password in source. You should instead obtain it
' from an interactive prompt, environment variable, or a secrets vault.
ftp.Password = "myPassword"
success = ftp.Connect()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Connected through the SOCKS proxy.") & "</pre>"
success = ftp.Disconnect()
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( ftp.LastErrorText) & "</pre>"
Response.End
End If
%>
</body>
</html>