Managing IPC Sessions

I have a overview question to start. In my efforts in playing with IPC Sockets to have my desktop app talk with my console app I find managing the path file a bit difficult. By that I mean in the IDE I start both apps, I run the connection from sender to received just fine. If I close the sender then restart it and try again I get an instant 103 error until I restart the receiver app. I know that the 103 means it is having a problem seeing or recognizing the IPC socket path file.

How do you manage from the desktop app the console app’s IPC Socket? ie. if the receiving side console app gets terminated and a new one appears using the same path file how to you address that with the desktop sending app? Until I restart the desktop app that example fails with a 103. Am I crazy? :slight_smile: perhaps :slight_smile:

Thanks again everyone. Your help is always appreciated.

Hard code a path and when the receiver drops off the sender listens again waiting for a new receiver to connect

Cool thanks Norman.

you might be able to use autodiscovery as well
makes it possible to be more dynamic

Norman thank you. I never had seen autodiscovery yet so I am looking at the LR now. Thanks!

I see that the autodiscovery is based on EasyUDP Sockets :frowning: I will take another look at EasyTCP Sockets as it is proprietary and I like that to avoid any other IP addresses trying to connect to my socket :slight_smile: Thanks!

Norman (for my console app receiving side) would this be advisable to return the app back to listening after I “execute” other code after the connection?

From Receiving Console App

[code]
Function Run(args() as String) as Integer
#pragma Unused args

// Synchonronously Waiting for Instructions from Main App via IPC Connection

// Establish IPC Socket to Listen for GUI Tombstone APP Instructions
InterAppCommunications = New IPCInterCommunication
InterAppCommunications.Path = SpecialFolder.UserHome.Child(“IPC”).ShellPath

do
IPCListen
loop until AppRun = 0
End Function[/code]

Note: AppRun is a property boolean of App

From Receiving Console App IPCListen Sub method:

Private Sub IPCListen()
  if InterAppCommunications.IsConnected = false then
    InterAppCommunications.Listen
  end if
  
  do
    InterAppCommunications.Poll
  loop until InterAppCommunications.BufferIsEmpty
End Sub

Thanks again!

You could make your listening app an event-driven console app (create an event loop in .Run using DoEvents). Then you can treat both sides the same.

Thanks a bunch Tim. I will try that now.

Tim,
Thank you again for pointing out “Event Driven Console App” in which I didn’t even know was an option for me. I just flat out missed that since it is at the bottom of the Project Types (atleast is in RS2012R2).

For what I am doing the Event driven console app type is much more suited for what I need as I have been struggling with the “Console App” trying to keep my code sequencing in order.

Thank you once again.

Very happy to have helped.