|
Establish a connection with a server.
Syntax
object.Connect( [RemoteHost],
[RemotePort], [UserName], [Password],
[Timeout], [Options] )
Parameters
- RemoteHost
- A string which specifies the host name or IP address of the
server. If this argument is not specified, it defaults to the
value of the HostAddress property if it is defined.
Otherwise, it defaults to the value of the HostName
property.
- RemotePort
- A number which specifies the port to connect to on the server.
If this argument is not specified, it defaults to the value
of the RemotePort property. A value of zero indicates that
the default port number for this service should be used to
establish the connection.
- UserName
- A string which specifies the user name which will be used to
authenticate the client session. This value must specify a valid
user name and cannot be an empty string. If this argument is not
specified, it defaults to the value of UserName property.
- Password
- A string which specifies the password which will be used to
authenticate the client session. If the user does not have a
password, this value can be an empty string. If this argument
is not specified, it defaults to the value of the Password
property. If the server requires public/private key authentication,
set the PrivateKey property to the name of the file
containing the private key prior to calling this method.
- Timeout
- The number of seconds that the client will wait for a response
before failing the operation. If this argument is not specified,
the value of the Timeout property will be used as the default.
- Options
- A numeric value which specifies one or more options. If this
argument is omitted or a value of zero is specified, a default
connection will be established. This argument is constructed by
using a bitwise operator with any of the following values:
Value |
Constant |
Description |
0 |
sshOptionNone |
No options specified. A standard terminal session will be
established with the default terminal type. |
1 |
sshOptionKeepAlive |
This option specifies the library should attempt to
maintain an idle client session for long periods of time. This
option is only necessary if you expect that the connection will
be held open for more than two hours. This option is the same
as setting the KeepAlive property to a value of
true. |
2 |
sshOptionNoPTY |
This option specifies that a pseudoterminal (PTY) should
not be created for the client session. This option is
automatically set if the Command property specifies a
command to be executed on the server. |
4 |
sshOptionNoShell |
This option specifies that a command shell should not be
used when executing a command on the server. |
&H40000 |
sshOptionPreferIPv6 |
This option specifies the client should prefer the use of
IPv6 if the server hostname can be resolved to both an IPv6 and
IPv4 address. This option is ignored if the local system does
not have IPv6 enabled, or when the hostname can only be resolved
to an IPv4 address. If the server hostname can only be resolved
to an IPv6 address, the client will attempt to establish a
connection using IPv6 regardless if this option has been
specified. |
Return Value
A value of zero is returned if the connection was successful.
Otherwise, a non-zero error code is returned which indicates the
cause of the failure.
See Also
HostAddress Property,
HostName Property,
Options Property,
Password Property,
PrivateKey Property,
RemotePort Property,
UserName Property,
Disconnect Method,
OnConnect Event
|
|