DataFlex
DataFlex
Log In After ConnectOnly on an FTP Server
See more FTP Examples
Demonstrates the Chilkat Ftp2.LoginAfterConnectOnly method, which authenticates a control connection previously established by ConnectOnly. It takes no arguments, sends USER, PASS, and ACCT when required, then performs normal post-login initialization.
Background: This is the second half of the two-step connect. Beyond sending the credentials, it runs the same post-login setup
Connect would — for example issuing TYPE I and any auto-negotiated features — so the session ends up in the same ready state either way. The value of the split is entirely in what you can do in the gap between the two calls.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
// Demonstrates the Ftp2.LoginAfterConnectOnly method, which authenticates a control connection
// previously established by ConnectOnly. It takes no arguments and sends USER, PASS, and (when
// required) ACCT, then performs normal post-login initialization.
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComPort Of hoFtp To 21
// First connect without logging in.
Get ComConnectOnly Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Set credentials (for example, after inspecting the greeting), then log in.
Set ComUsername Of hoFtp To "myFtpLogin"
Set ComPassword Of hoFtp To "myPassword"
Get ComLoginAfterConnectOnly Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Logged in."
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure