tags:

views:

2873

answers:

5

I would like to implement a robust IPC solution between a single JVM app (one process, potentially multiple threads) and a native C++ application that is linked to a C++ dll. The dll may or may not be on the same physical machine. What is the best approach for doing so?

Any suggestions will be greatly appreciated! Thanks!

+5  A: 

I'd use a standard TCP/IP socket, where the app listens on some port and the library connects to it to report what it has to report and expect the answers.

The abstraction is robust, well supported and will have no interop issues.

Vinko Vrsalovic
+1  A: 

Have you considered Facebook's Thrift framework?

Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk, and OCaml.

Thrift allows you to define data types and service interfaces in a simple definition file. Taking that file as input, the compiler generates code to be used to easily build RPC clients and servers that communicate seamlessly across programming languages.

It can work over TCP sockets and the serialization/deserialization is already built-in.

Read the whitepaper for details.

Swaroop C H
Thrift would be great, but I see the first sentence in their docs here say it won't work on Windows...am I interpreting that correctly?http://wiki.apache.org/thrift/ThriftInstallationWin32
A: 

mmm - DLLs are not processes, so I'm assuming you mean IPC between your Java app, and some other native application that is linked to the DLL. Sockets, for certain, are the way to go here. It will make everything easier for you.

Another option would be to use JNI to talk to a DCOM implementation, but I don't think you'll gain much (other than having to deal with the headaches of COM and JNI :-) ).

Kevin Day
+3  A: 

Google protocol buffer can help you serialize data in a language and platform neutral way. It will also generate code in Java and C++ to handle reading and writing the serialized data. You can then use any communication mechanism you wish to send the data. For example, you could send it over a TCP socket or via shared memory IPC.

cdv
A: 

I am looking at the Remote Call Framework, for my purely C++ apps. The specs look pretty and promising. I am going to try it.