DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myFtpLogin"
// SocksVersion selects the proxy: 0 (default) = none, 4 = SOCKS4, 5 = SOCKS5.
Set ComSocksVersion Of hoFtp To 5
Set ComSocksHostname Of hoFtp To "socks.example.com"
Set ComSocksPort Of hoFtp To 1080
// SOCKS5 supports username/password authentication; SOCKS4 uses only a user identifier.
Set ComSocksUsername Of hoFtp To "myProxyLogin"
Set ComSocksPassword Of hoFtp To "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.
Set ComPassword Of hoFtp To "myPassword"
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Connected through the SOCKS proxy."
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure