问题
I'm looking for a way to implement RPC between Java and C. What are the options to do this?
Best Wishes
p.s I have web java application which is hosted on Glassfish server and C daemon. I need to directly call functions from bought sides.
回答1:
The whole point of RPC is to let two opaque processes on different systems talk to each other over a network. The languages used are irrelevant, except that you have to learn the corresponding RPC libraries for both languages.
回答2:
Google Protocol Buffers address some of the difficulties with serialization, and provide a "RPC service" abstraction. You'll need to implement the "remote" part -- sending the data across, etc. -- but it'll give you cross-language compatible serialization.
The Google implementation doesn't natively support C -- only C++ -- but it looks like C is one of the languages for which there is an add-on.
回答3:
Another option is the open source "thrift" library (originally from facebook). It also supports generating local stubs in a multiple of languages. Though I suspect the protocol buffer library as suggested by @Louis Wasserman is higher quality than thrift.
回答4:
There are couple of java libraries implementing oncrpc:
http://code.google.com/p/nio-jrpc/ and http://sourceforge.net/apps/trac/remotetea/wiki/WikiStart.
来源:https://stackoverflow.com/questions/9269350/remote-procedure-call-between-java-and-c