Connect Method

Establish a connection with the specified FTP or HTTP server.

Syntax

object.Connect([ServerName] [,ServerPort] [,UserName] [,Password] [,Timeout] [,Options])

The Connect method syntax has the following parts:

Part Description
object An object expression that evaluates to a FileTransfer object.
ServerName A string which specifies the host name or IP address of the server.
ServerPort A long integer which specifies the server port number.
UserName A string which specifies the username.
Password A string which specifies the password.
Timeout A long integer which specifies the timeout period in seconds.
Options A long integer which specifies one or more options.

All parameters are optional. Any missing parameter defaults to the value of the property with the same name.

Return Type

Integer

Settings

The settings for Options are:

Value Constant Description
1 fileOptionNoCache This instructs an HTTP server to not return a cached copy of the resource. When connected to an HTTP 1.0 or earlier server, this directive may be ignored.
8192 fileOptionSecureExplicit This option specifies that the client should use the AUTH server command to tell an FTP server that it wishes to explicitly negotiate a secure connection. This requires that the server support the AUTH TLS or AUTH SSL commands. Some servers may not require this option, and some may require the option only if a port other than 990 is specified. If this option is specified, the control will automatically establish a secure connection.

Remarks

The Connect method is used to establish a connection with the specified server. This is the first method that must be called prior to the application transferring files or issuing FTP commands.

If the Connect method is called when a connection already exists, the current connection will be closed.

It is permissible to specify a complete URL as the first argument to the method and the connection will be established with the server using specified protocol. Passing a complete URL to the Connect method has the same effect as setting the URL property and then calling the method with no arguments.

This method will return a value of zero if the action was successful. Otherwise, a non-zero error code is returned which indicates the cause of the failure.

Additional properties that affect the operation of the Connect method are:

  • KeepAlive Property (HTTP)
  • ProtocolVersion Property (HTTP)
  • ProxyPassword Property
  • ProxyPort Property
  • ProxyServer Property
  • ProxyType Property
  • ProxyUser Property
  • Secure Property
  • ServerType Property
  • URL Property

If the ServerType property has the value fileServerUndefined, then the Connect method will try to infer the server type from the value of the ServerPort property. If the server type cannot be automatically determined, an error will be returned and the server type must be explicitly specified.

Examples

Example 1:

nError = FileTransfer1.Connect("www.bigcorp.com", 80)
If nError > 0 Then
    MsgBox FileTransfer1.LastErrorString, vbExclamation
    Exit Sub
End If

Example 2:

nError = FileTransfer1.Connect("http://wwww.bigcorp.com")
If nError > 0 Then
    MsgBox FileTransfer1.LastErrorString, vbExclamation
    Exit Sub
End If

See Also

KeepAlive Property, Options Property, Secure Property, ServerType Property, ServerName Property, ServerPort Property, UserName Property, Password Property, Timeout Property, URL Property


Copyright © 2008 Catalyst Development Corporation. All rights reserved.