Private Sub Form_Load()
Winsock1.RemotePort = 1001 ' or other availabe port
Winsock1.RemoteHost = 127.0.0.1 ' address assigned by default to localhost
Winsock1.Connect
Winsock2.LocalPort = 1002 ' having multiple controls for sending and recieving speeds things up
Winsock2.Listen
End Sub
Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close ' close Winsock1 if open; not
' likely but saves errors
Winsock1.Accept requestID
End Sub
Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim str As String
Winsock2.GetData str
'then do something with str, such as putting it in a public variable, or using
' Select Case to define a list of accepted commands.
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Unable to send data.", vbOKOnly + vbExclamation, "Error"
End Sub
Private Sub Winsock2_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Unable to recieve data.", vbOKOnly + vbExclamation, "Error"
End Sub
'more code...
Winsock1.SendData data
' you would then have similar code on the other app, but with the ports the other
' way around.