|
Summary
Connect, disconnect or abort an FTP session.
Description
The Action property controls the connection state of the FTP Client ActiveX control. An FTP session can be established, closed or aborted by assigning one of the following values to the
property.
| Value |
Meaning |
| ACTION_ABORT |
Abort session. |
| ACTION_CONNECT |
Establish session. |
| ACTION_DISCONNECT |
Close session. |
| ACTION_FW_CONNECT |
Establish session via a firewall. |
| ACTION_CANCEL |
Cancel any action. |
This property can be changed at run time only.
Before setting the Action property to ACTION_CONNECT, the following properties must be initialized. The Host property must be set to the name or internet address (in dotted decimal notation) of the
FTP server. The Port property must be set to the remote port on which the FTP service is running (most servers use the default FTP service port of 21). The User and Password properties must contain a
valid user name and password to complete the login process. Some servers also require that the Account property contain the name of an account for the user. Most applications will prompt the user
with a dialog box for the information to place into these properties, but all of them can also be specified at design time.
If the FTP Client machine is located on a different subnet than the remote FTP Server machine and the only form of communication between these two machines is through a firewall gateway, then the
built-in firewall support of the FTP Client ActiveX control can be used to established an FTP session. To establish a connection with a remote FTP Server through a firewall, set the Action property
to ACTION_FW_CONNECT. Before setting the Action property to ACTION_FW_CONNECT, the following properties must be initialized. The FirewallServer property must be set to the name or internet address
(in dotted decimal notation) of the firewall server. The FirewallPort property must be set to the firewall service port. In addition to the FirewallServer and FirewallPort properties, the Host, User,
Port, Password, and Account properties must also be set as mentioned above. Depending on the type of address specified in the Host property the FwAddrType property must be accordingly set, if the
Host property contains the IP address of the remote host then the FwAddrType must be set to FW_ADDR_IP4 and if contains a machine name then the FwAddrType property must contain FW_ADDR_DNS. Distinct
FTP ActiveX Control supports both SOCKS version 5 and SOCKS version 4, the application can specify the SOCKS version in the FwSocksVer property. If the SOCKS version is 5 then the application can
specify a authentication method in the FwAuthMethods property, currently only the Username/Password (FwUsername and FwPassword) authentication protocol is supported.
If the connection can be established, then the OnConnect event will be fired. If the connection cannot be established, then the OnError event will be fired. These events will occur before the next
statement (i.e. the statement following the assignment of ACTION_CONNECT to the Action property) is executed. The application should set a flag in the OnConnect and OnError events, so that it can
determine if the session has been established or not. In addition, the application may want to display an error message in the OnError event to inform the user that the connection has not been
established. Please check the reference page of the OnError event for a complete listing of error codes.
While an action is in progress, it can be canceled by setting the Action property to ACTION_CANCEL. Actions that can be aborted include trying to establish an FTP session, transferring a file,
listing a directory, and any directory or file manipulations.
Once a connection is no longer needed, the session can be terminated by setting the Action property to ACTION_DISCONNECT. An application must close all connections it has created before it quits. A
connection can also be closed by setting the Action property to ACTION_ABORT. This action resets and closes the connection without properly closing down and should not be called under normal
circumstances.
The Connect, Disconnect, Abort, FwConnect, and Cancel methods accomplish the same as the above actions. Please check the reference pages of these methods for more detailed information on their usage.
The value of the LastResult property can be checked to determine if the action has been performed successfully. There is no default value for this property.
Example
FTPClient.Host = "speedy.distinct.com" FTPClient.User = "santa" FTPClient.Password = "north pole" FTPClient.Account = "sc001d"
FTPClient.Action = ACTION_CONNECT
Note
If you are writing a new application it is recommended to use the corresponding methods for these actions instead.
|