Re: Linux and OS wide events
- From: Josef Moellers <josef.moellers@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Aug 2008 15:17:48 +0200
neelsmail@xxxxxxxxxxxxxx wrote:
On Aug 13, 4:12 pm, Josef Moellers <josef.moell...@fujitsu-
siemens.com> wrote:
neelsm...@xxxxxxxxxxxxxx wrote:Hi,Have a look at dbus.
I am new to Linux programming (been couple of months). I am writing an
app that needs to dispatch events using C++ (to start with). Event
subscriber can be any app on the machine. I know how would I do this
on Windows but I am not able to figure out how can I do that on Linux.
For an example, if my app changes configuration, I should be able to
send OnConfigurationChanged() event. Can you tell me how I can do that
on Linux?
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details:http://www.fujitsu-siemens.com/imprint.html
Thanks for your reply. I looked a dbus and it seems that it may
increase the dependency which may not be allowed in my project. Isn't
it possible to use something simpler instead?
- App that wants to receive a event loads a DL(L).
- Adds itself as a subcriber
- Shared library keeps track of all the event subscribers (This is
where I am stuck at) and once event is fired, sends the notification.
In windows, in theory, I should be able to do it using DLLs with
shared segment but on linux I am confused about .so and .dl and how to
implement shared dll that has the same copy of data for irrespective
of how many subscribers load it.
As Jens writes, two processes do share read-only code but do not share writable data ... in general.
You could do what you want with a shared memory segment, but (without thinking it through to the end), I would estimate that process synchronization and storage management will be a nightmare.
But you don't have to use dbus (although it's always best to use some tried-and-tested components), but you could whip something up yourself:
Take a single process which opens a (e.g. unix domain) socket and waits for processes to connect. On connected sockets, it then receives registration requests and messages. Registration requests will cause the socket the request appeared on to be added to the list of sockets messages of the requested kind will be "broadcasted" to. Messages will be sent to each socket that has been registered for that messages' types.
YMMV,
Josef
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
.
- Follow-Ups:
- Re: Linux and OS wide events
- From: Rainer Weikusat
- Re: Linux and OS wide events
- References:
- Linux and OS wide events
- From: neelsmail
- Re: Linux and OS wide events
- From: Josef Moellers
- Re: Linux and OS wide events
- From: neelsmail
- Linux and OS wide events
- Prev by Date: Re: Linux and OS wide events
- Next by Date: Re: Linux and OS wide events
- Previous by thread: Re: Linux and OS wide events
- Next by thread: Re: Linux and OS wide events
- Index(es):
Relevant Pages
|