Using a CSocket across thread boundaries
-
I have a CSocket object that I need to share between two threads in two different objects (one thread in each object). I am using a Console App that supports MFC using VC++ 6.0. I create the CSocket object in the 'main' function of the console app and then pass a pointer to the CSocket into the 2 objects. I then fire up the threads in the two objects. When I try to perform a 'Receive' call on the CSocket in the thread, I get an assertion error. The line that crashes is 'ASSERT(pState->m_hSocketWindow != NULL)' found in 'CSocket::PumpMessages()'. I checked the pointer value of the CSocket and it matches the CSocket object that was created in the 'main'. I know there are certain MFC objects that cannot be shared across thread boundaries - is the CSocket one of them? Thanks!
-
I have a CSocket object that I need to share between two threads in two different objects (one thread in each object). I am using a Console App that supports MFC using VC++ 6.0. I create the CSocket object in the 'main' function of the console app and then pass a pointer to the CSocket into the 2 objects. I then fire up the threads in the two objects. When I try to perform a 'Receive' call on the CSocket in the thread, I get an assertion error. The line that crashes is 'ASSERT(pState->m_hSocketWindow != NULL)' found in 'CSocket::PumpMessages()'. I checked the pointer value of the CSocket and it matches the CSocket object that was created in the 'main'. I know there are certain MFC objects that cannot be shared across thread boundaries - is the CSocket one of them? Thanks!
take a look at this ^ Tom Wright tawright915@yahoo.com
-
take a look at this ^ Tom Wright tawright915@yahoo.com
Thanks a lot! That's exactly what I needed to know!