C++ RPC library suggestions [closed]
Asked Answered
B

8

13

I'm looking for suggestions regarding RPC libraries implemented in C++, for C++ developers.

Some requirements constraints:

  • Should work on both linux/unix and win32 systems
  • Be able to execute free function and class methods
  • Hopefully written in modern C++ not 90's/java-esque C++
  • Be able to function over networks and hetrogenous architectures
  • Not too slow or inefficient
  • Hopefully provide interfaces for TR1 style std::function's et al.

My example usage is to invoke the free function foo on a remote machine.

---snip---
// foo translation unit
int foo(int i, int j)
{
   return i + j;
}
---snip---


---snip---
// client side main
int main()
{
   //register foo on client and server
   //setup necassary connections and states

   int result;

   if (RPCmechanism.invoke("foo",4,9,result))
      std::cout << "foo(4,9) = " result << std::endl;
   else
      std::cout << "failed to invoke foo(4,9)!" << std::endl;

   return 0;
}
---snip---

Something that can achieve the above or similar would be great.

Note: I am NOT interested in other language bindings. Please do not proffer a solution because it has other language bindings. I'm only interested in well designed RPC frameworks written in C++ for the C++ language, that are efficient and appropriate for HPC scenarios.

Basic answered 4/12, 2010 at 5:34 Comment(1)
possible duplicate of Cross-platform general purpose C++ RPC libraryOverreach
W
8

That's quite a set of requirements...

While not meeting all of them (as I'm not sure that any such beast exists - I commend to your attention ICE from ZeroC. Developed in part by Michi Henning of CORBA fame (and ask your friends in telecom, that really isn't a dirty word), ICE is what CORBA would have looked like if it started later and wasn't developed by a committee.

Their C++ mapping is everything that CORBA is not, it uses STL types, and is generally newer feeling.

It fails the free-function and std::function tests, but given the improbability of finding a product for that entire list, this does a good job of many of the remainder.

Good Luck

Wallacewallach answered 5/12, 2010 at 1:42 Comment(1)
The CORBA IDL to C++ mapping does not use STL, but the IDL to C++11 language mapping is now fully using STL and uses all new features of C++11.Livelihood
E
7

I am also interested in viable C++ RPC implementations. After some research, I found that etch, thrift and protocol buffers are the most promising solutions, however none of them actually meets all my needs. My search criteria are:

  1. multi-language, with C++ and PHP as a must (C#, Java, Python, Perl are not so important right now)
  2. the server can compile/run only on Linux (with Windows as a long-term goal)
  3. the client must run on Windows and Linux (and possibly Mac)
  4. open source and commercial friendly (that is, no GPL)
  5. it must support encryption out of the box

And the candidates are:

  1. Apache Etch

    Pros:

    • the C binding is based on the APR
    • supports encryption
    • runs on both platforms

    Cons

    • slow development
    • lacks a PHP binding
  2. Apache Thrift

    Pros:

    • small
    • multiple language bindings

    Cons:

    • currently, it doesn't support encryption (under development, at least for the C++ binding)
    • on Windows, it requires Cygwin
  3. Protocol Buffers with an in-house developed RPC solution

    Pros:

    • small
    • multiple language bindings

    Cons:

    • no built-in RPC

Currently, I am evaluating the possibility to develop the RPC layer for Protobuf using APR.

However, search continues...

EDIT: I managed to work through some of these issues by using Apache Qpid (C++ version) with protobuf for serialization, although it currently lacks some features that I need.

Epithelioma answered 1/1, 2011 at 3:32 Comment(0)
O
5

old ones like DCE-RPC, CORBA,

or Protocol Buffers, or Thrift, Etch,

or web ones like SOAP, or REST.

Which one you want depends on what you want to do. eg. fast and efficient RPC for a local network would require a lightweight, binary RPC like Protocol Buffers, but a RPC for heterogenous web services would require the much more verbose SOAP.

Google uses PB for all its internal RPCs so it's a good choice. Facebook uses Thrift so its hardly a small player, and MS likes SOAP.

Overreach answered 4/12, 2010 at 14:0 Comment(3)
Protobuffers is a message serialization, SOAP is a COM equivelent and REST is a web2.0'ism that has nothing to do with C++, tr1 std::functions etc...Basic
Protobuf supports RPC services: code.google.com/apis/protocolbuffers/docs/proto.html#servicesGeometry
Does it provide a mechanism as is disucssed in the question, or does it require further work to get that kind of functionality?Basic
D
3

Have you tried thrift, http://thrift.apache.org/ ?

Dulcine answered 4/12, 2010 at 13:35 Comment(3)
It should work both on linux/unix and win32, does thrift work on win32?Basic
Check wiki.apache.org/thrift/ThriftInstallationWin32Dulcine
Even though win32 programming can be done using MinGW and cygwin, Traditionally win32 programming is done using msvc, I don't see any mention of msvc win32 .Basic
B
2

Check out FastRPC, http://fastrpc.sourceforge.net/ .

Becalm answered 4/12, 2010 at 11:41 Comment(1)
I had a look at it, the C++ API doesn't seem to suggestion free or class methods can it invoked, seems more like a ProtoBuffers-like library. For example say I have a function foo such as int foo(int i, int j) { return i+j} - how does one register foo with a server entity and then how does one invoke foo on the server from the client with the param 4 and 9 ?Basic
L
2

RCF looks to be what you want: http://www.deltavsoft.com/index.html

Lettuce answered 4/10, 2012 at 13:7 Comment(1)
Is GPL. Could be problematic for some applications.Heyduck
T
1

you can use protobuf implement one by yourself, and add all you wanted featrue. It is not too hard, and you can get many benefit from it.

Tannie answered 4/12, 2010 at 11:59 Comment(2)
The question required a library, I'm not interested in rolling out my own.Basic
Protobuf supports some RPC-like functionality. Though it might be a little extra work to get it to behave a certain way.Geometry
D
1

The following code, pulled from an example TAO CORBA client, shows that 3 lines of code are required to connect to a server, and one line of code to call a function. Note that the function call looks like a native local function call. This can either be a free function, or a member function.

// Bring in the IOR
Object_var factory_object =  orb->string_to_object (argv[1]);

// Now downcast the object reference 
My_Factory_var factory = My_Factory::_narrow (factory_object.in ());

// Now get the full name and price of the other arguments:
Widget_var widget = factory->get_widget (argv[i]);

// Get its name, put it on a _var so it is automatically
// released!
String_var full_name = widget->full_name ();

// Now get the price
Double price = widget->price ();

cout << "The price of a widget in \""
  << full_name.in () << "\" is $"
  << price << endl;

The server code is a little more complex to show, but in CORBA, for what you are looking to do, mostly, you create an IDL interface, run it through the compiler, then fill in your app logic in the appropriate slot in the stub. So, your main code looks like the following:

// First initialize the ORB, that will remove some arguments...
ORB_var orb = ORB_init(argc, argv, "ORB" /* the ORB name, it can be anything! */);
Object_var poa_object = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(poa_object.in());
PortableServer::POAManager_var poa_manager = poa->the_POAManager();
poa_manager->activate();

// Create the servant
My_Factory_i my_factory_i;

// Activate it to obtain the object reference
My_Factory_var my_factory = my_factory_i._this();

// Put the object reference as an IOR string
String_var ior = orb->object_to_string (my_factory.in());
orb->run();

    // Now in your stub file generated by the idl compiler, 
    char * Widget_i::full_name (

  )
  ACE_THROW_SPEC ((
    ::CORBA::SystemException
  ))
{
  return "Some widget name";
}

::CORBA::Double Widget_i::price (

  )
  ACE_THROW_SPEC ((
    ::CORBA::SystemException
  ))
{
  return 1.25;
}

Have a look at This WikiBook for more references and examples

Deshabille answered 3/1, 2011 at 2:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.