fsClientInit

Creates an FTP client.

Syntax:

fsClientInit( host, port, user-name, password [, protocol] )

Parameters:

(s) host: FTP server domain name including sub domains.

(i) port: FTP command port - usually port 21 or port 22 with @fsSFTP.

(s) user-name: name of user account on server.

(s) password: password for user account on server.

(i) protocol: [optional] @fsFTPES, @fsFTPS, @fsFTP, @fsSFTP.

Returns:

(s) client-handle: An FTPS extender client handle used by the other extender functions. 

FsClientInit creates an FTPS extender client handle. The client handle is the first parameter to most of the other function in this extender. It can be used multiple times with any extender function that takes it as a parameter. The handle becomes invalid once the fsClientDelete function is called on the handle or called to delete all handles.

 

host

Place the full domain name part of an FTP server's URL in this parameter. Do not include the namespace part of the server URL.

 

port

Use this parameter to indicate the port number of the FTP server's command channel. Almost all servers use port 21 unless the server still uses the deprecated implicit FTPS protocol. If implicit FTP (@fsFTPS)  is used,  you likely need to use port 990. Use port 22 with SFTP (@fsSFTP) protocol.

 

user-name

 This parameter is used to indicate the name associated with an FTP server's user account that has sufficient privileges to perform tasks executed by other extender functions. Some servers require a domain name as part of the user name so they can perform domain based authentication. For example, "ftp.example.com|examuser" where the server domain name is  "ftp.example.com" and the user account name is "examuser". Notice that the two parts are separated by a vertical bar(|). This separator character my vary because it is depended on the server's FTP implementation.

 

password  

Use this parameter to provide the password associated with the user-name user account.

 

protocol

An optional parameter used to indicate FTP protocol to use. The default is @fsFTPES.

 

Use one of the following extender defined constants as a value:

 

Protocol

Meaning

@fsSFTP (3)

SFTP provides the Secure File Transfer Protocol over the Secure Shell (SSH) cryptographic

network protocol for secure data communication between two networked systems. SFTP can be used

with either a password or a public-key/private-key pair. Because of the security issues associated

with passwords, public-key/private-key pair authentication is generally considered more secure.

The SFTP server determines whether you can use a password and/or a public-key/private-key pair.

@fsFTPES (2)

(default) Use the explicit FTPS protocol. Best choice and supported by most servers.

@fsFTPS (1)

Use implicit FTPS protocol. This protocol is deprecated and should only be used when a server does not support explicit FTPS

@fsFTP (0)

Unencrypted FTP protocol. Only use when FTPS is not supported.

Note that the WinInet extender supports more functionality with the plain FTP protocol.

Note: If you need to or chose to use a public-key/private-key pair with @fsSFTP, you will need to generate a key-pair that the server supports. The public-key is stored on the server so if you do not have control of the server, you will need to contact the server administrator. The private-key can be stored in the <system drive>:\users\<user_name>\.ssh directory of your system. Because the extender uses the Windows built-in implementation of SSL/TSL, it requires the private-key be stored by the ssh-agent Windows service. Starting with Windows 10 build 1809 the ssh-agent service and command line tool along with other openSSH tools are available as an optional feature. Microsoft website contains documentation of the Windows implementation of openSSH tools. You can use the ssh-keygen utility to generate a key-pair with the correct sever supported digital signature algorithm. The "ed25519"  algorithm is considered the safest, fasted, and most often supported algorithm.  Openssh tools for older versions of Windows can be found on the Github Website.

 

Example:
  AddExtender('ilcfs44i.dll',0,'ilcfs64i.dll'
  host = 'test.example.com'
  port = 21
  user = 'demo'
  pwd  = 'password'
  
  ; 1. Use the default protocol (@fsFTPES)
  client = fsClientInit(host, port, user, pwd)
  
  ; Perform file and directory tasks as needed...
  
  ; Disconnect the client and free extender resources
  fsClientDelete(client)
  
  ; 1. Use the deprecated implicit FTPS protocol (@fsFTPS)
  port = 990
  client = fsClientInit(host, port, user, pwd, @fsFTPS)
  
  ; Perform file and directory taskes as needed...
  
  ; Disconnect the client and free extender resources
  fsClientDelete(client)
See Also:

fsClientDelete, fsDisconnect