SecureTcp Object : Connect Method |
Visual Basic |
---|
Public Sub Connect( _ ByVal RemoteName As String, _ Optional ByVal RemotePort As Long = 443, _ Optional ByVal LocalName As String, _ Optional ByVal LocalPort As Long = 0 _ ) |
This method initiates a connection and a secure negotiation with a secure server. This method blocks if Timeout is greater than 0. The Blocked Property may be checked to verify the control is not executing another method.
If Protocol specifies a security protocol and the server does not support that protocol, then the Error event fires (and an error will be returned if Timeout is greater than 0) with Number=ptProtocol and Description="Security protocol negotiation failed." The State event fires twice as the State changes to ptClosing and ptClosed, respectively.
If the server requests authentication and the Certificate property does not reference a valid certificate (by the time the Certificate Event returns) then the Error event fires (and an error will be returned if Timeout is greater than 0) with Number=ptNoCertificate and Description="There was an error in creating credentials." Typically this means the digital certificate referenced by the Certificate property could not be found. If the server closes the connection the State event fires twice as the State changes to ptClosing and ptClosed, respectively.
If the server does not authenticate then the Error event fires (and an error will be returned if Timeout is greater than 0) with Number= ptAuthentication and Description="The server could not be authenticated." The State event fires twice as the State changes to ptClosing and ptClosed, respectively.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):