(Swift) Use Explicit FTP over TLS
Demonstrates how to connect to an FTP server using explicit FTP over TLS.
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let ftp = CkoFtp2()!
ftp.hostname = "ftp.your-ftp-server.com"
ftp.username = "ftpAccountLogin"
ftp.password = "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.
ftp.authTls = true
// Connect and convert the connection to TLS automatically.
var success: Bool = ftp.connectOnly()
if success != true {
print("\(ftp.lastErrorText!)")
return
}
success = ftp.loginAfterConnectOnly()
if success != true {
print("\(ftp.lastErrorText!)")
return
}
print("TLS connection established and successfully authenticated.")
}
|