Zig
Zig
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 Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const ftp = try chilkat.Ftp2.init();
defer ftp.deinit();
ftp.setHostname("ftp.example.com");
ftp.setUsername("mylogin");
ftp.setPassword("mypassword");
// Connect and login to the FTP server.
ftp.connect() catch {
std.debug.print("{s}\n", .{try ftp.getLastErrorText(alloc)});
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 (ftp.getIsConnected()) {
std.debug.print("Connected!\n", .{});
} else {
std.debug.print("Not connected!\n", .{});
}
// ...
try ftp.disconnect();
}