Get reference to instance of daemon class

  • Thread starter Michael Ransburg
  • Start date
M

Michael Ransburg

Hi!

I have implemented a daemon in C++. It runs all the time, between
reboots. Is there a way for other C++ classes to get a reference to
the instance of this daemon class in order to call its methods
directly?

E.G.:

1) System Start - daemon class is instantiated and launched
2) System Start + 5 Minutes: user class is instantiated and launched
3) user instance wants to access methods of daemon instance
4) user instance calls "getClassInstance('daemon')" to get a reference
to the instance of the daemon class
5) user calls daemon.getInformation();

It's step 4) I'm not sure how to do.

Any assistance would be highly appreciated.

Thanks,
Michael
 
V

Victor Bazarov

Michael said:
I have implemented a daemon in C++. It runs all the time, between
reboots. Is there a way for other C++ classes to get a reference to
the instance of this daemon class in order to call its methods
directly?

If there is, it's very OS-specific. Please ask in a newsgroup
dedicated to your OS. Inter-process communication is not part
of C++ language.

V
 
R

raj

Hi!

I have implemented a daemon in C++. It runs all the time, between
reboots. Is there a way for other C++ classes to get a reference to
the instance of this daemon class in order to call its methods
directly?

E.G.:

1) System Start - daemon class is instantiated and launched
2) System Start + 5 Minutes: user class is instantiated and launched
3) user instance wants to access methods of daemon instance
4) user instance calls "getClassInstance('daemon')" to get a reference
to the instance of the daemon class
5) user calls daemon.getInformation();

It's step 4) I'm not sure how to do.

Any assistance would be highly appreciated.

Thanks,
Michael

hey Michael

This is not a c++ question. Please google for shared memory / inter
process communciation for your operating system

Raj
 
J

JKop

Michael Ransburg posted:
Hi!

I have implemented a daemon in C++. It runs all the time, between
reboots. Is there a way for other C++ classes to get a reference to
the instance of this daemon class in order to call its methods
directly?

E.G.:

1) System Start - daemon class is instantiated and launched
2) System Start + 5 Minutes: user class is instantiated and launched
3) user instance wants to access methods of daemon instance
4) user instance calls "getClassInstance('daemon')" to get a reference
to the instance of the daemon class
5) user calls daemon.getInformation();

It's step 4) I'm not sure how to do.

Any assistance would be highly appreciated.

Thanks,
Michael

Well regardless of your target platform, you'll want to do something like
the following in your prog:


Daemon* daemon = new Daemon;


Now, you'll have to agree on a rendevouz point in order for your "user" one
to know where this daemon is. Maybe something like a Mutex or something
would work, giving it a predefined name, let's say "DaemonnomeaD".

Now, the other prog will do something like the following:

Daemon* current_daemon = GetTheAddressOfThatDaemonFromWherever();

current_daemon->getInformation();



If you're planning on writing some sort of virus or spyware, I suggest you
hit the books, you haven't near enough knowledge to pull it off at the
moment!


-JKop
 
M

Michael Ransburg

Thanks for your answer!
If you're planning on writing some sort of virus or spyware, I suggest you
hit the books, you haven't near enough knowledge to pull it off at the
moment!

Just curious, why do you assume that I want to do such a thing?

Best regards,
Michael
 
J

JKop

Michael Ransburg posted:
Thanks for your answer!


Just curious, why do you assume that I want to do such a thing?

Best regards,
Michael


Airgead
Geld
Dinero
Argent
Soldi
Dinheiro
Money


That would be a motive.

But the name "Daemon" suggested it to me. I see all sorts of crappy worms
and viruses with names like "Gremlin", "Annihilator".


-JKop
 
M

Michael Ransburg

Airgead
http://en.wikipedia.org/wiki/Daemon_(computer_software)

You might want to do a little homework before slinging accusations.

Indeed, I'm actually researching some more efficient (exotic? ;-)) IPC
possibilities for a project I'm involved at the University where I'm
doing my pHD right now ;-) It got me a little surprised (and curious)
to find myself in the position of an accused spyware writer so quickly
;-)

Best regards,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top