PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Ftp
li_Success = 0
loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
destroy loo_Ftp
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Ftp.Hostname = "ftp.example.com"
loo_Ftp.Username = "myFtpLogin"
// SocksVersion selects the proxy: 0 (default) = none, 4 = SOCKS4, 5 = SOCKS5.
loo_Ftp.SocksVersion = 5
loo_Ftp.SocksHostname = "socks.example.com"
loo_Ftp.SocksPort = 1080
// SOCKS5 supports username/password authentication; SOCKS4 uses only a user identifier.
loo_Ftp.SocksUsername = "myProxyLogin"
loo_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.
loo_Ftp.Password = "myPassword"
li_Success = loo_Ftp.Connect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
Write-Debug "Connected through the SOCKS proxy."
li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
destroy loo_Ftp