Re: CAsyncsocket derived class being run as a thread

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



You don't have to use AfxBeginThread to start your thread

You can do something like

UDPListener* pThread = new UDPListener ();

pThread->SetReceivePort( iPort);

pThread -> CreateThread ();  // this could go in your Start() function


paul@xxxxxxxxxxx wrote:
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

  • Re: CAsyncsocket derived class being run as a thread
    ... Can I access the member functions like this: ... messages from the specified port. ... will the UDP packets still be received? ... packet listener to do it in a loop. ...
    (microsoft.public.vc.mfc)
  • Re: Asynchronous UDP Sockets ~ No Read events!
    ... > WSAEnumNetworkEvents(s, hEvent, &NetworkEvents); ... > // There is some logic here to exit the loop when necessary that is ... > As the comments above say, the FD_CONNECT and FD_WRITE events fire. ... > It only doesn't fire when packets arrive from another computer. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Has anybody configured a Draytek router for multiple IP ranges?
    ... input IP - (specified port) ... would have been more obvious because that defines the packets you are ... The destination of the packet is nothing to do with it. ... with multiple hosts attached. ...
    (uk.telecom.broadband)
  • Asynchronous ICMP
    ... I have seen some posts here about asynchronous ICMP and I am having a little ... problem with threading. ... I have a large number of hosts to ping. ... I send out 10 ICMP packets and call the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: performance and timing issues udp socket
    ... > essentially allows selection of number of offered packets per second. ... > number of packets sent and thus the actual throughput. ... > As a test bed i simply connect to the loop back address 127.0.0.1 of my ...
    (comp.lang.perl.misc)