views:

603

answers:

4

We have a C++ application on Windows that starts a java process. These two apps need to communicate with each other (via snippets of xml).

What interprocess communication method would you choose, and why?

Methods on the table for us are: a shared file(s), pipes and sockets (although I think this has some security concerns). I'm open to other methods.

+4  A: 

I'm not sure why you think socket-based communication would have security concerns (use SSL). It is often a very good approach as it is language agnostic, assuming that you have a well-defined communication protocol. Have a look at Google's protocol buffers, for example - they generate the required Java classes and streams.

In my experience, file systems (especially network file systems) are not well suited to such communication as they are not necessarily tuned for messaging (I've seen caching issues result in files being not picked up by the target process for example).

Another option is a messaging layer (AMQ or Tibco for example) although this will likely involve a greater administrative overhead (plus expertise) to set up.

Personally I would opt for a pure-socket approach because of its flexibility and simplicity. You will be in complete control.

oxbow_lakes
Your point is taken about sockets and security. Thanks. +1
David Coufal
+1  A: 

Ice is pretty cool :)

Draemon
+2  A: 

I've used named pipes for communication between C# and a cross-platform c++ app and had nothing but good results. Barring that sockets is definitely the way to go.

Ron Warholic
+1  A: 

Sockets are nice. They give you the ability to very easily create a blackbox testing layer around each component, as well as run each component on its own machine.

Security is definitely a concern, but there are a good range of options depending on how important it is. You can use SSL, custom handshaking, password protected logins and firewalls to help secure it.

Edit: Not something I'd recommend, but there's also shared memory using JNI. Just thought I'd mention it because it's not on your list.

patros