Qt and RPC



  • Hi Guys,

    Has anyone used RPC (Remote Procedural Calling) within their C++ Qt Application.

    I have been able to create a client/server application using the RpcGen which generates the c code client and server stubs. The client sends two numbers to the server which computes the sum of the two and returns the value. Now my goal is to take this minimalist approach and integrate it into a C++ Qt application. The problem I am having is that all of the tutorials for RPC shows the C application being executed via the command line passing in the args.. i.e. ./applicationName arg1 arg2.

    I would rather not use QProcess to execute the similar command. Instead be able to create the client within my Qt app and call the RPC procedure as well.

    Is this possible?

    Any help is appreciated, Thank you!


  • Qt Champions 2016

    I have, over DBus. It's your best bet if you have it available (Linux) otherwise there are other possibilities but I'm not aware of any Qt-ready solution. I've read about remote QObject s' methods being called and it's apparently part of the Qt Mobility (I think available through the commercial license).



  • Integrate ur rpc client code as library in qt application and call in qt program.



  • @kshegunov

    I am not sure if this solution would work for my application. Reason being the server code is already implemented on a separate system running RPC. I am mainly concerned with creating the Client. The Client will have to use the same .x file used by RpcGen to generate the Procedures. Can I use Qt D-Bus to communicate to the RPC Server using the same Procedures and ultimately get the same results as a RPC Client to RPC Server communication?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    From what you wrote, you already have this working using a small CLI. In that case, you can write a wrapper class that will use the code generated by RpcGen then use that class in your application.



  • @dheerendra

    I had tried this approach but was receiving undefined reference errors to the Procedure created by RpcGen that had no definition. Using the .x file RpcGen would create the Client's .h and executable but no .c where the definition would reside. But the executable could be executed via the terminal ./appName arg1 arg2 with no errors. Therefore during compile/build time RpcGen handled the function definitions when generating the binaries. This is an area that I am unfamiliar with, it leaves me thinking that in order to use the Rpc procedures you must use the Rpc generated Client executables but this cannot be true?



  • I have decided to go with the route of using QProcess to start a detached Client process and pass in the according parameters. I will update if changed


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.