UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » Is possible to call remote function in another daemon?

#1 2011-05-04 07:38 PM

rcbanditl
Guest

Is possible to call remote function in another daemon?

Hi,
   Is it possible to call a remote function in another daemon? Here is the setup:
   I have two daemons daemon A with function "s" and daemon B with function "k". I need a way function "s" from daemon A to call a function "k" from daemon B and pass some arguments. When the request is processed function "k" returns the output to function "s". Is this possible?

Regards
Peter

#2 2011-05-05 12:15 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Is possible to call remote function in another daemon?

Well, there's stuff like Sun RPC you could use...  But, personally, I'd just roll my own protocol to handle it...  Just define some command/query that when received by daemon B it knows to call the function (with args taken from the request message), and send back the results...  If you only want this to be doable by this other daemon and not anyone that can communicate with deamon B, then you'll have to add some kind of authorization to it, as well...

Offline

#3 2011-05-05 02:31 PM

rcbanditl
Guest

Re: Is possible to call remote function in another daemon?

Sun RPC is for server/client arhitecture for two machines which communicate via network. Is there other way?

#4 2011-05-05 06:57 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Is possible to call remote function in another daemon?

Well, it doesn't matter too much if they're on the same computer or across the Net from each other...  If you want the function to actually be run in the context of the other daemon, then you would be best off coordinating it with that other daemon, so it knows WTF is going on, one way or another...  I mean, there's stuff like ptrace() that would let you force the other process to run whatever you want, but it's generally not a good idea to just go hijacking another process behind its back like that, outside of debugging purposes...  If, on the other hand, you just want to run the function in your own daemon, without bothering the other daemon at all, then simply put the function into a shared library that you both link to (or dlopen()), and then you can call it at will...

Offline

#5 2011-05-06 01:38 AM

rcbanditz
Guest

Re: Is possible to call remote function in another daemon?

I found other solutions: CORBA, DBUS and SUNRPC. The problem is that CORBA and SUNRPC are not supported anymore the last version is from arround 2004. ptrace() seems very interesring option.
Thank you for the ideas!
Is it possible two daemons to have one namespace so they can call functions from each other?
Any other solution?

Regards

#6 2011-05-06 12:18 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Is possible to call remote function in another daemon?

Is it possible two daemons to have one namespace so they can call functions from each other?

Sure, just make them separate threads within the same process...

Offline

#7 2011-05-06 03:40 PM

rcbanditz
Guest

Re: Is possible to call remote function in another daemon?

From a post in internet I found that one process can call a function in another process and receive a result. Can anyone show such a example in C?

Regards

#8 2011-05-06 07:55 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: Is possible to call remote function in another daemon?

What post, where?

Offline

  • Index
  • » C
  • » Is possible to call remote function in another daemon?

Board footer

Powered by FluxBB