I am developing a system which involves 2 applications in a client-server environment. Let's call them AppA and AppB. AppA is the main beast, and may have multiple concurrent instances running on different machines across a LAN. Certain events must be notified to other instances, so I'm using a protocol across Winsock controls to do this. Now this is where AppB comes in. I need a 'Server' (poor choice of term perhaps) to coordinate the communications across Winsocks on instances of AppA. So AppB maintains an array of Winsocks, adding to it as necessary when an instance of AppA is started, and 'logs on' by sending .Connect through its own Winsock as follows...
With Winsock1
.RemoteHost = "127.0.0.1"
.RemotePort = 1007
.Connect
End With
AppB 'hears' this with
Private Sub Socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
If Not mbOperatorLogonLocked Then
mbOperatorLogonLocked = True
mnSockets = mnSockets + 1
Load Socket(mnSockets)
With Socket(mnSockets)
.LocalPort = 1007
.Accept requestID
End With
Set mtmpWorkstation = New clsWorkstation
Set mtmpWorkstation.Socket = Socket(mnSockets)
End If
End Sub
Now that's all very well, but if there is an instance of AppA running on the same machine which is hosting AppB, it can't connect. Something to do with 127.0.0.1?
How should AppA recognise that it is running on the machine which is hosting AppB, and then what is the correct .RemoteHost value for its Winsock?
Thanks if you can answer this for me.
Andy Ellis