Hi,
With the IPCSocket connection(on Mac) example, it seems that only 2 connections could communicate as a server and client.
I’m considering to keep multiple slaves(through console app) for communicating with Server through IPCSockets.
Is there any way to keep multiple IPCSockets connections from Server to many slave console apps?
Array of IPCSockets?
Yes, an array of sockets would be the way to go. When creating helper apps, I usually spin up a socket on a particular path and then launch the helper app, giving it the path on the command line, so the two can easily link up.
The path needs to be unique for each connection, so you want something more like:
for i as integer = 1 to NumberOfChildApps
mysockets(i).Path = SpecialFolder.Temporary.Child("com.example.ipcsocketexample").NativePath + str(i)
...
next
Also, if you re-use an existing path (from an app that crashed) you will get a 105 error when trying to re-use it. In that case you should have code to .Close the socket then try again.
This is a conversation I have been looking for for a while and am trying to wrap my ahead. I have 7 console applications that access a db with multiple schemas and tables and can do that in their own time depending on outside sources.
Now that the db has grown the value modifications in the db are at times incorrect and that is because the console apps access the db in similar times, grab the data and modify as they need to. However before they write their data the referenced information is now changed but not known by that particular console app and creates db data integrity problems
It is time to implement Inner Process Communications to ensure db data integrity on a per console application basis. I am trying to envision how to implement IPC with multiple console apps. The arrayed aspect appears to be what I need but after several attempts that did not work it appears there needs to be a Master and others act as slaves. Then is that is accurate how to implement an array of IPC sockets and enable full IPC communications without sacrificing the speed these apps have as console apps is needed.
So if any of this makes sense I am looking to get me head wrapped around this to be able to implement multiple IPC communications and enable db data integrity
[quote=198351:@Carl Fitzsimmons]<…> However before they write their data the referenced information is now changed but not known by that particular console app and creates db data integrity problems
<…>[/quote]
I think you would have to deal with this issue just like with any other multiuser database: you need a timestamp per record, to keep track of last modification time.
The console apps need to retrieve this timestamp and upon saving, it will only update if the timestamp is still the same. Otherwise it would have to retrieve the data again and restart its task from scratch.
Use transactions and/or triggers to accomplish this.
Interesting. I did not occur to me to implement such a strategy. While I am still interested in the IPC aspect this makes sense to apply such a strategy. Lets see what happens. Thanks
[quote]@Marcus Winter That is a good read as well and will look at Vlad next article.[/quote] Between IPC, time stamp, record locking and potentially optimistic locking the solution exists.
7 console apps are set to ‘Listen’ using the same global scoped strings
One global scope string per console app
All 7 are defined in the ‘CONNECT’ console app
Inside each console app ‘Listen’ or ‘Connect’ I placed these globals:
[quote]‘myIPCsocket’ with Super = ‘IPCsocket’ and defined all 3 Event Handlers ‘Connected’, ‘DataAvailable’ , ‘Error’
newsockets defined as type myIPCsocket
mySockets() with Type myIPCsocket
[/quote]
I created 7 IPCsockets using the following inside the Run event of APP
When I start up all ‘Listen’ console apps then I start the ‘Connect’ console app all is good. Things work as I would expect.
Doing some testing I quite the ‘Connect’ console app and restarted. Then the ‘Error’ event in myIPCsocket throws 103 which means it cannot resolve the hostname
[code] Dim x As Integer
For x = 0 to 6
newsockets = New myIPCsocket
mySockets.Append newsockets
'This is where the separate IPCSocket folders are defined using global strings myIPCSocket_folder1...7
Select Case x
Case 0
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder1).NativePath
Case 1
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder2).NativePath
Case 2
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder3).NativePath
Case 3
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder4).NativePath
Case 4
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder5).NativePath
Case 5
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder6).NativePath
Case 6
mySockets(x).Path = SpecialFolder.Temporary.Child(myIPCSocket_folder7).NativePath
End
'Now connect
mysockets(x).Connect
Next
[/code]
Any thoughts on how to resolve the 103 and or whats causing the error?
When you quit the connect app, all the listeners must detect that and start listening again. Otherwise, there’s nothing to connect to when the connect app restarts.