Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Determine if Connected and Logged On
See more FTP Examples
The IsConnected property indicates whether or not the FTP component has a valid TCP/IP connection (and is logged on) to the FTP server.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Ftp2;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
ftp: TFtp2;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
ftp := TFtp2.Create;
ftp.Hostname := 'ftp.example.com';
ftp.Username := 'mylogin';
ftp.Password := 'mypassword';
// Connect and login to the FTP server.
success := ftp.Connect();
if (success <> True) then
begin
WriteLn(ftp.LastErrorText);
Exit;
end;
// ...
// At any point in an FTP session, the IsConnected property
// can be checked to determine if the component has remained
// connected to the FTP server.
if (ftp.IsConnected = True) then
begin
WriteLn('Connected!');
end
else
begin
WriteLn('Not connected!');
end;
// ...
success := ftp.Disconnect();
ftp.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.