Re: Losing UDP packets with MFC Sockets



OK, I understand now. But with this implementation, I see a problem: how can
I close the socket from the main thread? Should I use Windows messaging?

Vicent

"Scott McPhillips [MVP]" wrote:

> Vicent Soler wrote:
> > I'm not sure about your thread solution:
> >
> > - Are you saying that I sould derive my class from both CAsyncSocket and
> > CWinThread?? With this king of inheritage, the OnReceive notification will be
> > implemented in specific thread different from the main thread, right? If I
> > want to access the derived class from the main thread, could exist any
> > conflict? Should I use Critical Section in every method of the class? Please,
> > let me know any sample, if possible...
> >
> > Thanks, I hope it works...
> >
> > Vicent
>
> I'm not saying use multiple inheritance. I'm saying, if you want to use
> a thread, you must use the kind that is derived from CWinThread. Put
> your socket into your thread as a member variable. Call the socket only
> from the thread. If you put the socket in such a thread you cannot
> access it or use it from the main thread.
>
> What you can do is copy the received data to the heap and pass the heap
> pointer to the main thread using PostMessage to the main window.
>
> --
> Scott McPhillips [VC++ MVP]
>
>
.