Is it possible to call function with DBUS on the same machine

Peter Penzov peter.penzov at gmail.com
Fri May 6 15:49:31 PDT 2011


Hi,
  Can you implement this in a working code. Sorry but I'm not C expert. I
started to learn C from several weeks.
This is a very valuable for me, I'm sure many people will use it too.

Regards
Peter

On Sat, May 7, 2011 at 1:33 AM, Marcus Nascimento <marcus.cps at gmail.com>wrote:

> You may use a something like this (pseudo alike code):
>
> // Method 1 parameters structure
> typedef struct {
>   int methd1param1;
>   gchar method1param2[20];
> } method1_st;
>
> // Method 2 parameters structure
> typedef struct {
>   int method2param1;
>   int method2param2;
>   int method2param3;
> } method2_st;
>
> // other methods declaration
>
> // Method call structure
> typedef struct {
>   int methodId,
>   union params {
>     method1_st method1params;
>     method2_st method2params;
>     // other methods parameters.
>   } method_call;
>
> Then, you fill a method_call structure with the Id of the method you want
> to call.
> And them you can fill the parameters of this method inside the union.
> Then you have to serialize that method_call into an array of bytes to send
> it to the other side.
> In the other side, you do the oposite.
>
> Note that the union gives you guarantee on the size of the method call.
> So you don't have to read the first field (method id) to know how many
> bytes you need to read after to get all the parameters.
> I know this is a waste of bandwidth/memory, but it makes your code much
> simpler. Tradeoffs are there everytime.
>
> You may face some trouble with threads and SIG_PIPE when you use sockets.
> If you decide to go this way, I can give you some hints.
>
> I know iIt is cumbersome, but it was the best option to me. Maybe not for
> you.
>
> I did something like this, but I used a much more complex structure based
> on C++ and polimorphism to automate the serialization and deserialization
> work.
> It is working very smooth. I'm sorry not to provide you the real code. I
> did it in my work and I cant open that to you.
>
> There are a lot of options to do serialization. I went to a "do it
> yourself" approach, but you may use some of the available libs around.
> If I remember well, there is a library called FUSION that does that.
> There is a Google library that does that.
>
> I'm not really the best person to talk about serialization. Maybe you can
> ask some general forum on that.
>
> Regards.
> Marcus
>
> On Fri, May 6, 2011 at 7:12 PM, Peter Penzov <peter.penzov at gmail.com>wrote:
>
>> Hi,
>>   I know that there is IPC solution but as far as I know it can only be
>> used to send simple message to other daemon. I don't have idea how I can
>> call a remote function using Unix Domain Socket (AF_UNIX) to call a
>> function.
>>
>> Any idea?
>>
>> Regards
>> Peter
>>
>>
>>
>> On Sat, May 7, 2011 at 1:08 AM, Marcus Nascimento <marcus.cps at gmail.com>wrote:
>>
>>> Hi,
>>>
>>> In fact, yes! There is. You can use more general IPC systems like
>>> Sockets, Pipes, Shared Memory and so on.
>>> I like Sockets very much. In fact, DBus itself is based in unix sockets.
>>>
>>> You have to choose deppending on your needs. What do you want to do?
>>> Maybe I can help you.
>>>
>>> I had some trouble recently with Dbus because its C implementation (dbus
>>> glib porting) imposes the use of a GMainLoop for signal support. That wasn't
>>> possible because I was working on a library to be linked into a very large
>>> gamma of embedded systems. So I chose Sockets and implemented a full custom
>>> solution for my needs.
>>>
>>> Marcus.
>>>
>>> On Fri, May 6, 2011 at 7:01 PM, Peter Penzov <peter.penzov at gmail.com>wrote:
>>>
>>>> Hi,
>>>>    I found alternatives to DBUS but it seens that they are outdated:
>>>>
>>>> Orbit(Corba) - is seems that it's not developed since 2004
>>>>
>>>> SunRPC - it's too not maintained
>>>>
>>>> Linux Doors - it's not maintained
>>>>
>>>> There is internal RPC in Linux that I may use
>>>> http://www.cs.cf.ac.uk/Dave/C/node33.html
>>>>
>>>> Is there another way to call a remote function?
>>>>
>>>> Regards
>>>>
>>>> Peter
>>>>
>>>>
>>>> On Fri, May 6, 2011 at 11:32 PM, Marcus Nascimento <
>>>> marcus.cps at gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> As far as I know, DBUS can handle only one call at a time for a given
>>>>> service (daemon).
>>>>>
>>>>> I tried to use feedback this way and it failed (A calling "k" and B
>>>>> calling "s" inside the body of "k").
>>>>> I know It is possible to use signals while a given call is ongoing.
>>>>>
>>>>> I'm not exactly sure about this, anyone more skilled than me may say
>>>>> the opposite.
>>>>> Maybe you should go for a Prove of Concept.
>>>>>
>>>>> Regards.
>>>>> Marcus
>>>>>
>>>>>
>>>>> On Fri, May 6, 2011 at 4:47 PM, Peter Penzov <peter.penzov at gmail.com>wrote:
>>>>>
>>>>>>  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
>>>>>> _______________________________________________
>>>>>> dbus mailing list
>>>>>> dbus at lists.freedesktop.org
>>>>>> http://lists.freedesktop.org/mailman/listinfo/dbus
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20110507/b85e13d1/attachment.htm>


More information about the dbus mailing list