sktConnect

This method requests a connection to a remote computer. If the object is declared using the WithEvents option, then an OnConnect event is available in the script environment.

Syntax: oSocket.sktConnect([vRemoteHost], [vRemotePort])

vRemoteHost       (Variant) Optional – allows a connection to a host that is not specified in the RemoteHost property

vRemotePort        (Variant) Optional – allows a connection to a host that is not specified in the RemotePort property

Group :Socket Object

Example:

Dim WithEvents oSocket As Socket ' module level Dim

Set oSocket = New Socket

oSocket.Protocol   = sckTCPProtocol

oSocket.RemoteHost = "127.0.0.1"

oSocket.RemotePort = 21097

oSocket.sktConnect

Private Sub oSocket_OnConnect()

  On Error Resume Next

  '

Set oSocket = New Socket

  Do

Loop Until oSocket.State <> sckConnecting

If oSocket.State <> sckConnected Then App.MsgBox "Connect failed."

End Sub