Rust
Rust
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 Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let ftp = chilkat::Ftp2::new();
ftp.set_hostname("ftp.example.com");
ftp.set_username("mylogin");
ftp.set_password("mypassword");
// Connect and login to the FTP server.
if ftp.connect().is_err() {
println!("{}", ftp.last_error_text());
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.is_connected() {
println!("Connected!");
} else {
println!("Not connected!");
}
// ...
let _ = ftp.disconnect().is_ok();