Making Remote Procedure Calls

Hello,

Another question, I have two applications (a master and a slave) that need to work together.
I have the slave sending information back to the master, but now I still need a way for the master to send orders to the client.

My first guess would be to create a TCP channel and send a text message with the order and the applicable arguments.
The client application should then interpret the text message and do something in response.
When the client is done, I would like him to send a message with the result back, after which the master can close the TCP channel.
Basically this would be a making Remote Procedure Calls.

I found that there are a number of libraries that should be useful in this scenario, but so far I was not able to build one that I could use successfully (that might be due to my lack of understanding).

So now I see two options:
1. Try to make it myself (+ I would learn and understand what happens, - it is not likely that my implementation will be as fast/good or better as currently existing solutions).
2. Find a library that I can build using GCC and that is either easy enough for me to use or documented extensively.

In either case I would prefer to write a single class for the master and a single class for the client to do this.

I would appreciate any tips, links tot tutorials and examples that can help me with this challenge.

For option 1, I think something like:
on the server side:
- constructor define some static values (like IP-address, port and so on)
- a function to send a command-string
this function should repeat sending the string until it receives an acknowledgement
subsequently it should wait for the result and return the result as a std::string
(this function could be called from multiple threads simultaneously)

on the client side:
- constructor that opens a port and listens for connections.
if a connection is made, it should be handled in a separate thread.
- the thread should send e.g. "ok" to acknowledge that the command was received.
- subsequently the thread should interpret the command-string and execute the appropriate action.
for example the command-string "print:15" should make the client print the number 15 in its console.
- finally the thread should return a string that returns the result, e.g. "0" or "done" and close the TCP connection

Again, I would appreciate any tips, links tot tutorials and examples that may help me with this challenge.
Topic archived. No new replies allowed.