Menu

strang behaviour with SocketPort ...

Help
Anonymous
2000-10-25
2000-11-06
  • Anonymous

    Anonymous - 2000-10-25

    I derived a class from SocketPort

    class MyPort : public virtual SocketPort
    {
    public:
        MyPort(SocketService *s)
         : SocketPort(s, InetHostAddress(), 5678) {};
    protected:
        virtual void Pending() {
            cout << TID << ": TimeServer received packet:";
     
            char buffer[1000];
            int  len;
     
            len = Recv((void *) buffer, 1000);

            cout << buffer << " (" << len << " byte)" << endl;
        }
    };

    In my code I tried two variants.

    variant a:

    ...
    SocketService * pss;
    pss = new SocketService(0);

    MyPort m(pss);

    for (;;) {} ; // endless loop

    -------------------------------------------
    variant b:

    ...
    SocketService * pss;
    pss = new SocketService(0);

    MyPort *pm
    pm=new MyPort(pss);

    for (;;) {} ; // endless loop

    -----------------------------------------------

    variant a behaves as I expected: It dumps every UDP packet on Port 5678. variant b doesn't receive any packet. It creates all classes/threads and then does nothing.

    Is this a bug? The two variants differ imho only in the fact, where MyPort is created (on the stack or on the heap). Why is the behaviour different then?

    Stefan

     
    • David Sugar

      David Sugar - 2000-11-06

      This I will have to setup a test case for.  I know gcc has had odd problems in the past with objects created in the "stack frame", so if anything, I would almost expect varient a to fail and b to work!  Which platform and compiler are involved here??

       
      • Anonymous

        Anonymous - 2000-11-06

        .I use gcc 2.95.2 on Linux 2.2.14 i686 unknown.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.