Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using a CSocket across thread boundaries

Using a CSocket across thread boundaries

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toothless boots
    wrote on last edited by
    #1

    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!

    T 1 Reply Last reply
    0
    • T toothless boots

      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!

      T Offline
      T Offline
      Tom Wright
      wrote on last edited by
      #2

      take a look at this ^ Tom Wright tawright915@yahoo.com

      T 1 Reply Last reply
      0
      • T Tom Wright

        take a look at this ^ Tom Wright tawright915@yahoo.com

        T Offline
        T Offline
        toothless boots
        wrote on last edited by
        #3

        Thanks a lot! That's exactly what I needed to know!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups