|
|
Establish a connection with a remote server.
Syntax
object.Connect( [RemoteHost],
[RemotePort], [UserName], [Password],
[Timeout], [Options] )
Remarks
This method establishes a network connection with a remote
server. All arguments are optional. If a given argument is missing,
then a corresponding property or properties must be set before
attempting the connection, as follows:
- RemoteHost
- A string which specifies the host name or IP address of the
remote host. 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 remote
host. 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
- An optional string which specifies a username used to
authenticate the client session. This argument is only required if
access to the resource requires authentication. If this argument is
omitted, it defaults to the value of the UserName property.
An empty string means that no authentication will be
performed.
- Password
- An optional string which specifies the password used to
authenticate the client session. This argument is only required if
access to the resource requires authentication. If this argument is
omitted, it defaults to the value of the Password property.
An empty string means that no password will be provided.
- Timeout
- The number of seconds that the client will wait for a response
before failing the operation. A value of zero indicates that the
client should wait an indefinite period of time. If this argument
is not specified, the value of the Timeout property will be
used as the default.
- Options
- A bitmask which specifies one or more options. If this
parameter is omitted, it defaults to the value of the
Options property. This parameter is constructed by using a
bitwise operator with any of the following values:
| Value |
Constant |
Description |
| 1 |
httpOptionNoCache |
This instructs the 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. |
| 2 |
httpOptionKeepAlive |
This instructs the server to
maintain a persistent connection between requests. This can improve
performance because it eliminates the need to establish a separate
connection for each resource that is requested. If the server does
not support the keep-alive option, the client will automatically
reconnect when each resource is requested. Although it will not
provide any performance benefits, this allows the option to be used
with all servers. |
| 4 |
httpOptionRedirect |
This option specifies that the
client should automatically handle resource redirection. If the
server indicates that the requested resource has moved to a new
location, the client will close the current connection and request
the resource from the new location. Note that it is possible that
the redirected resource will be located on a different server. |
| 8 |
httpOptionProxy |
This option specifies that the
client should use the default proxy configuration for the local
system. If the system is configured to use a proxy server, then the
connection will be automatically established through that proxy;
otherwise, a direct connection to the server is established. The
local proxy configuration can be changed using the system Control
Panel. |
| 4096 |
httpOptionSecure |
This option specifies that the
client should attempt to establish a secure connection with the
server. Note that the server must support secure connections using
either the SSL or TLS protocol. This option is only available in
the Secure Editions of SocketTools. |
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
AutoRedirect
Property, HostAddress
Property, HostName
Property, ProxyHost
Property, ProxyPort
Property, ProxyType
Property, RemotePort
Property, RemoteService Property,
URL Property, Disconnect Method, OnConnect Event
|
|