PowerBuilder
PowerBuilder
Set FTP Connection and Read Timeouts
See more FTP Examples
Demonstrates the timeout properties ConnectTimeout, ReadTimeout, and IdleTimeoutMs.
Background: The three timeouts guard different phases:
ConnectTimeout (in seconds) bounds how long a connection attempt blocks so an unreachable server fails promptly; ReadTimeout (seconds) limits how long a data connection may stall without new data; and IdleTimeoutMs (milliseconds) caps a lack of forward progress overall. Tuning them prevents a hung server or flaky link from freezing an automated job indefinitely.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"
// Maximum seconds to wait for the TCP connection to be accepted.
loo_Ftp.ConnectTimeout = 15
// Maximum seconds a data connection may go without receiving more data before timing out.
loo_Ftp.ReadTimeout = 30
// Maximum milliseconds without a control-channel response or forward progress before failing.
loo_Ftp.IdleTimeoutMs = 20000
// 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 timeouts."
li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
Write-Debug loo_Ftp.LastErrorText
destroy loo_Ftp
return
end if
destroy loo_Ftp