...
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2000-11-06
.I use gcc 2.95.2 on Linux 2.2.14 i686 unknown.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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??
.I use gcc 2.95.2 on Linux 2.2.14 i686 unknown.