The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

C++ Help requested by jayfarm 2009-04-02 06:41:22
So, I have an object that has methods and members, and it has another object that handles it's IO.

I'm doing packet-capture, and the pcap libraries require a static call-back method.

So what I did was create a wrapper function in the main module. When I start monitoring for packets I store a the pointer for "this" in a global static variable, and the wrapper is a static method that does:

myModule me = (myModule) pointerToModule;
me.callback(args);

And during the callback it does things - stores new information in the member variables.

I've found that for some reason I then have to update the pointer after I change the data. And that my main method that kicked all this off doesn't see any updates to the information done during this callback.


So... How do I solve this problem? How do I push these updates to the object that is instantiated already?

C++ isn't my primary language, so I'm a bit out of my depth here and hoping for some help.

Thanks in advance,
Jay
[ Reply ]
  Based on your description by Arachnid2009-04-02 06:47:30
    Let me trim it up by jayfarm2009-04-02 07:03:34
    Posted a sample by jayfarm2009-04-02 07:55:25
  Code chunks below by jayfarm2009-04-02 07:48:15
    testmain.cpp by jayfarm2009-04-02 07:48:42
    mymodule.cpp by jayfarm2009-04-02 07:50:45
  I may be blind, but I don't see... by RetiQlum22009-04-02 08:43:41
    Pointer is updated in mymodule by jayfarm2009-04-02 08:53:14
      I can't see the error. by RetiQlum22009-04-02 09:36:25
      Aren't you actually copying the object by pstradomski2009-04-02 10:02:06
        aw crap... by jayfarm2009-04-02 10:04:49
          Yes (n/t) by pstradomski2009-04-02 10:05:19
            trying now. by jayfarm2009-04-02 10:05:40
            Woo thanks! by jayfarm2009-04-02 10:08:08
  SOLVED - pstradomski spotted my rookie mistake. by jayfarm2009-04-02 10:08:51

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)