Connect Method

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 specifies that the default port number should be used. For standard connections, the default port number is 25. For secure connections, the default port number is 465. If the secure port number is specified, an implicit SSL/TLS connection will be established by default.
UserName
An optional string argument which specifies the user name to be used with authentication. If this argument is not specified, it defaults to the value of the UserName property. Note that for authentication to be performed, the Extended property must be set to True.
Password
An optional string argument which specifies the password to be used with authentication. If this argument is not specified, it defaults to the value of the Password property. Note that for authentication to be performed, the Extended property must be set to True.
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 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 smtpOptionNone No additional options are specified when establishing a connection with the server. A standard, non-secure connection will be used.
1 smtpOptionExtended Extended SMTP commands should be used if possible. This option enables features such as authentication and delivery status notification. If this option is not specified, the library will not attempt to use any extended features.
4096 smtpOptionSecure 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.
8192 smtpOptionSecureImplicit This option is used in addition to smtpOptionSecure. It should be specified when the server expects an implicit SSL connection.

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.

Remarks

Specifying a username and password as arguments to the Connect method only sets the default UserName and Password values. If authentication is required, the client must explicitly call the Authenticate method after the connection has been established.

See Also

Extended Property, HostAddress Property, HostName Property, RemotePort Property, RemoteService Property, Authenticate Method, Disconnect Method, OnConnect Event


Copyright © 2008 Catalyst Development Corporation. All rights reserved.