Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkFtp2W.h>
void ChilkatSample(void)
{
BOOL success;
HCkFtp2W ftp;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
ftp = CkFtp2W_Create();
CkFtp2W_putHostname(ftp,L"ftp.example.com");
CkFtp2W_putUsername(ftp,L"mylogin");
CkFtp2W_putPassword(ftp,L"mypassword");
// Connect and login to the FTP server.
success = CkFtp2W_Connect(ftp);
if (success != TRUE) {
wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
CkFtp2W_Dispose(ftp);
return;
}
// ...
// 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 (CkFtp2W_getIsConnected(ftp) == TRUE) {
wprintf(L"Connected!\n");
}
else {
wprintf(L"Not connected!\n");
}
// ...
success = CkFtp2W_Disconnect(ftp);
CkFtp2W_Dispose(ftp);
}