Sample code for 30+ languages & platforms
Unicode C

Use Explicit FTP over TLS

See more FTP Examples

Demonstrates how to connect to an FTP server using explicit FTP over TLS.

Chilkat Unicode C Downloads

Unicode C
#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.your-ftp-server.com");
    CkFtp2W_putUsername(ftp,L"ftpAccountLogin");
    CkFtp2W_putPassword(ftp,L"ftpAccountPassword");

    // Indicate that the "AUTH TLS" command should be use to convert the connection to TLS
    // after the initial TCP connection to port 21 is established.
    CkFtp2W_putAuthTls(ftp,TRUE);

    // Connect and convert the connection to TLS automatically.
    success = CkFtp2W_ConnectOnly(ftp);
    if (success != TRUE) {
        wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
        CkFtp2W_Dispose(ftp);
        return;
    }

    success = CkFtp2W_LoginAfterConnectOnly(ftp);
    if (success != TRUE) {
        wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
        CkFtp2W_Dispose(ftp);
        return;
    }

    wprintf(L"TLS connection established and successfully authenticated.\n");


    CkFtp2W_Dispose(ftp);

    }