Sample code for 30+ languages & platforms
PowerBuilder

Send an FTP NOOP (Keep-Alive)

See more FTP Examples

Demonstrates the Chilkat Ftp2.Noop method, which sends the FTP NOOP command. It takes no arguments and succeeds only when the server returns a positive reply.

Background: NOOP asks the server to do nothing and simply reply, which makes it the standard keep-alive: sending one periodically resets the server's idle timer so a long-running job does not lose its control connection between transfers. Because it exercises a real request/reply round trip, a successful NOOP is also firmer evidence the connection is alive than CheckConnection.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

//  Demonstrates the Ftp2.Noop method, which sends the FTP NOOP command.  It takes no arguments.
//  The server must return a positive reply for the method to succeed.

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"

//  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"

//  Connect and log in (Connect performs both).
li_Success = loo_Ftp.Connect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

//  NOOP does nothing on the server, but a successful reply confirms the control connection is
//  still responsive -- useful as a keep-alive during an otherwise idle session.
li_Success = loo_Ftp.Noop()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "NOOP acknowledged by the server."

li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if



destroy loo_Ftp