Re: CAsyncsocket derived class being run as a thread

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Joe and Scott,
Thanks for your replies - it will give me something to digest over the
weekend. A pity the kind souls at work haven't given me long enough to
actuall do any learning on the subject or testing. Sigh.

I did ask a rudimentary question about threading but its disappeared
from my news feed, so it
must have vanished. Anyway, what I asked was this:

If I do something like
pThread = AfxBeginClass (RUNTIME_CLASS (UDPListener)); // UDPListener
is derived from CWinThread

Can I access the member functions like this:
(UDPListener *) pThread->SetReceivePort( iPort); // set the listening
port
pThread->Start(); // start the thread going

If not, how can I access the thread functions?

Also, as you mention above, yes, I am using OnReceive(...) to receive
messages from the specified port. If I start a thread going, as
discussed above, will the UDP packets still be received? A friend at
work has written something in C# and suggested a while(true){ .... }
loop, with a call to UdpClient.Receive(...) placed in the middle of it
to pick up packets, but it just seems more natural (to me anyway!) to
let OnReceive(...) do everything rather than explicitly informing your
packet listener to do it in a loop.

.



Relevant Pages