Communication between applications

I have an application in WPF and I need to call another application executable made with Unity3D. These two application need to communicate with each other (send several types of information between the two).
I’ve used some types of communication between applications in the past (through executable parameters and mailslot), but my question is:
What is the best (fastest and reliable) communication method to use with an Unity3D application (for Windows)?

My thanks in advanced

Depends upon what you need. “Fastest and reliable” don’t really enter into it for most applications. Also, more often than not, fast and reliable are contrary terms. Something that is very fast often implies that it’s not very reliable.

In my opinion, named pipes are really your best option in general. Unity’s version of Mono.NET fully exposes System.IO.Pipes as long as you set the API compatibility level to “.NET 2.0” (as opposed to “.NET 2.0 Subset”). You can change that in the Player Settings. See the following MSDN article for an introduction to named pipes for interprocess communication in C#: How to: Use Named Pipes for Network Interprocess Communication - .NET | Microsoft Learn

The fastest way for any two processes to communicate is via shared memory. But, this is the lowest-level form of communication, so it’s not very reliable. You have to manage your own mechanisms for concurrent memory access (usually done with Mutexes – heavyweight mutual exclusive managers for shared resources). In C#.Net, this is actually pretty easy. MSDN has some articles on shared memory in managed applications. Search for “memory-mapped files”.

1 Like

Does anybody have current information on this? The System.IO.Pipes does not appear when I set API compatibility to .NET 2.0.

In the past (non-Unity) I used a MapView to have shared memory between two applications, but it was native code, not managed memory so I don’t know if that’s even possible or easy to do here. This is for a motion platform to hook up with my speedboat simulator (http://speedboatsim.com). It just needs to be able to read three vectors or so that I write to 100 times per second. If anyone has any ideas, I’d love to hear them.

I’ve used sockets in the past. Googling now, 5 years later, I see there’s still no better/easier option, so I’m using that again

I have used MemoryMappedFiles in the past, here is a implemenation I did to read Freetrack data in my WPF application.