PowerBuilder
PowerBuilder
FTP Socket Buffer and Address Options
See more FTP Examples
Demonstrates the SoRcvBuf, SoSndBuf, PreferIpv6, and ClientIpAddress properties.
Background: These are low-level knobs for specific situations. Larger send/receive buffers can improve throughput on high-bandwidth, high-latency links, though the defaults suit the common case.
PreferIpv6 only matters when a hostname resolves to both address families, choosing which to try first. ClientIpAddress is normally left unset; set it on a multihomed host to bind the outgoing connection to a particular local interface. Change any of these only with a concrete reason.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"
// SoRcvBuf and SoSndBuf set the TCP socket receive/send buffer sizes. The defaults are tuned for
// the common case; larger values can sometimes help throughput on high-latency links.
loo_Ftp.SoRcvBuf = 4194304
loo_Ftp.SoSndBuf = 524288
// PreferIpv6 (default 0) chooses IPv6 over IPv4 when a hostname resolves to both.
loo_Ftp.PreferIpv6 = 0
// ClientIpAddress is normally left unset; set it on a multihomed host to bind the outgoing
// connection to a specific local interface.
loo_Ftp.ClientIpAddress = "192.168.1.50"
// 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 with custom socket options."
li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
destroy loo_Ftp