tags:

views:

96

answers:

4

I have a set of functions in C/C++ that I need to be available to accept calls and return values to C/C++ code in a remote location, similar to RMI on the java platform. With RMI the Java methods are set up through the rmiregistry and remain available in memory to accept requests. I'm looking for similar functionality in C/C++, but i'm a bit confused with all the options that are out there. Is this type of scenario that CORBA was intended for and if so, is this still the best technology to use or are there better options out there. I've read about XML-RPC, CORBA, and a few others but i'm not sure which of these is what i need.

Thanks for your help.

Mike

A: 

There's no built in method for accomplishing this in C or C++. That said there are several libraries that can accomplish this.

If you're on Windows, then the best answer is probably DCOM, which is part of the OS itself. I'm not sure about other platforms.

Billy ONeal
Technically there is no built in method do do this in Java. Though it is part of the Java standard library.
Martin York
@Martin: Part of the standard library would be built in in my book. No separate language syntax is required; but it works out of the box.
Billy ONeal
@Billy ONeal: Its not part of the language or in the standard library but it still works out of the box in C++ as it is part of the Windows OS (Does this count as builtin)! In fact I would say it is easier than in Java as the extra configuration required for Java is not the trivial in comparison!
Martin York
@Martin: Windows OS doesn't count as builtin, and it doesn't work "out of the box", because c++ isn't constrained to Windows OS. When you install Java and Python, you get facilities to do this in the standard library. You do not in c++, you rely on third party libraries, like DCOM.
Stephen
+1  A: 

On Unix-like platforms, you're probably looking for Sun RPC (remote procedure calls).

CORBA is also relevant but has a more natural binding to languages with object oriented capability.

Drew Hall
+4  A: 

Is this type of scenario that CORBA was intended for and if so, is this still the best technology to use or are there better options out there.

Yes, this is what CORBA was intended to solve. Whether it's "best" is subjective and argumentative. :) I can say, from my personal experience, I don't miss my short experience with CORBA and would suggest you explore other options.

I've read about XML-RPC, CORBA, and a few others but i'm not sure which of these is what i need.

As you seem to be aware, you're looking for any technology that implements RMI (also frequently called RPC). It's not built-in to C/C++.

On Linux, there is SunRPC. I would also recommend looking at Google protocol buffers, which provide a mechanism for serializing data as well as an interface for defining RPC services. There are several service implementations available, but I don't have experience with the service implementations.

Stephen
Thanks everyone for the response. This is a big help especially for someone like me, new to this area of development. Based on the responses here it looks as though SunRPC is the clear choice. If i may ask, and i'm not looking for explicit details just generalities. How is SunRPC used, do i set up an application as a daemon (i'm using linux) and then accept calls to this daemon using SunRPC? i'm going to do some research but i'm just not seeing the full picture yet on how the different pieces work together. Thanks again though.
@mikeymo93: Yeah, that's an accurate description. You'll define an RPC interface, use `rpcgen` to generate client and server stubs. Then write a server that handles RPC requests (effectively a daemon) using the server stub. Then a client that uses the client stub to make the requests against the server.
Stephen
Here's a nice little tutorial: http://www.krzyzanowski.org/rutgers/hw/rpc/index.html
Stephen
@Stephen: Perfect, that's exactly what I needed to know to get started. Thanks again!
A: 

I shall suggest either CORBA or any webservice library available

CORBA is a reasonable choice for you (though it may be a little bit old technology for now). I have been using CORBA for several years in my previous job.

I should say, learning curve for CORBA is kind of steep, and you need to cater a lot of extra setup, but once it it done correct, it become smooth to use. (The problem is it takes really some time to use it correctly)

Webservice is an de facto industrial standard now, and I believe C++ will have some reasonable implementation and library for that. CORBA cover more features than WS but those feature are seldom used in simple systems.

Adrian Shum
@AdrianShum: Thanks for the feedback, I hear a lot about CORBA, but everyone says its already a dead technology. Is it worth learning. Or would it not be worth the time and energy to invest time getting to understand it? For the linux platform are CORBA, SunRPC and XML-RPC the standard choices for communication between processes?