DataFlex
DataFlex
Set an FTP Compatibility Option
See more FTP Examples
Demonstrates the Chilkat Ftp2.SetOption method, which enables or disables a named compatibility option. The only argument is the option name; matching is case-insensitive, and prefixing a recognized name with No- disables it.
Background: Real-world FTP servers have quirks, and these named options are targeted workarounds for specific ones — for example
Microsoft-TLS-1.2-Workaround addresses a known interoperability issue. Most applications never need any of them; reach for SetOption only when a documented server problem calls for a specific fix, and use the exact recognized name.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
// Demonstrates the Ftp2.SetOption method, which enables or disables a named compatibility option.
// The only argument is the option name. Prefix a name with "No-" to disable it.
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 ComUsername Of hoFtp To "myFtpLogin"
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
Set ComPassword Of hoFtp To "myPassword"
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Enable a recognized compatibility workaround. Option-name matching is case-insensitive.
Get ComSetOption Of hoFtp "Microsoft-TLS-1.2-Workaround" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// To disable it, prefix the name with "No-":
Get ComSetOption Of hoFtp "No-Microsoft-TLS-1.2-Workaround" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Compatibility option toggled."
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure