C
C
Clear the FTP Session Log
See more FTP Examples
Demonstrates the Chilkat Ftp2.ClearSessionLog method, which clears the in-memory FTP protocol log collected while KeepSessionLog is enabled. It takes no arguments.
Background: With session logging on, the
SessionLog accumulates the full FTP command/reply conversation, which is invaluable for diagnosing a failed transfer. Over a long-lived session it grows unbounded, so clearing it frees memory — and, more usefully, lets you capture the log for one specific operation in isolation by clearing just before and reading just after.Chilkat C Downloads
#include <C_CkFtp2.h>
void ChilkatSample(void)
{
BOOL success;
HCkFtp2 ftp;
success = FALSE;
// Demonstrates the Ftp2.ClearSessionLog method, which clears the in-memory FTP protocol log. It
// takes no arguments and is a void method.
ftp = CkFtp2_Create();
CkFtp2_putHostname(ftp,"ftp.example.com");
CkFtp2_putUsername(ftp,"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.
CkFtp2_putPassword(ftp,"myPassword");
success = CkFtp2_Connect(ftp);
if (success == FALSE) {
printf("%s\n",CkFtp2_lastErrorText(ftp));
CkFtp2_Dispose(ftp);
return;
}
// The SessionLog accumulates the FTP protocol conversation when KeepSessionLog is enabled, which
// is useful for debugging.
CkFtp2_putKeepSessionLog(ftp,TRUE);
// ... perform some operations ...
// Clear the log, for example before starting a new logical operation whose log you want to
// capture in isolation.
CkFtp2_ClearSessionLog(ftp);
printf("Session log cleared.\n");
success = CkFtp2_Disconnect(ftp);
if (success == FALSE) {
printf("%s\n",CkFtp2_lastErrorText(ftp));
CkFtp2_Dispose(ftp);
return;
}
CkFtp2_Dispose(ftp);
}