You are not logged in.
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?
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...
Sun RPC is for server/client arhitecture for two machines which communicate via network. Is there other way?
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...
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?
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?