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. CAysncSocket Notifications

CAysncSocket Notifications

Scheduled Pinned Locked Moved C / C++ / MFC
design
6 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi, I have a CAsyncSocket which is a member of a CWinThread class. The notifications however m OnSend, OnReceive seem to go the Main Thread. Do I need a Window or does the thread CWinThread ( a UI thread ) have to have the CDialog which is using CWinThread have it s m_pMainWnd point to a CDialog to get the notifications sent to that CWinThread Thanks

    V 1 Reply Last reply
    0
    • F ForNow

      Hi, I have a CAsyncSocket which is a member of a CWinThread class. The notifications however m OnSend, OnReceive seem to go the Main Thread. Do I need a Window or does the thread CWinThread ( a UI thread ) have to have the CDialog which is using CWinThread have it s m_pMainWnd point to a CDialog to get the notifications sent to that CWinThread Thanks

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      1. MFC class CWinThread does not have a member of the CAsyncSocket type. Perhaps, you meant that you created a CWinThread derived class which contain a CAsyncSocket derived object? 2. To handle CAsyncSocket notifications you have to override the CAsyncSocket::OnSend, CAsyncSocket::OnReceive and probably other virtual methods. See MSDN article Windows Sockets: Socket Notifications[^]

      F 1 Reply Last reply
      0
      • V Victor Nijegorodov

        1. MFC class CWinThread does not have a member of the CAsyncSocket type. Perhaps, you meant that you created a CWinThread derived class which contain a CAsyncSocket derived object? 2. To handle CAsyncSocket notifications you have to override the CAsyncSocket::OnSend, CAsyncSocket::OnReceive and probably other virtual methods. See MSDN article Windows Sockets: Socket Notifications[^]

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        CAsyncSocket is a member of my CWinThread Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread Thanks

        V 1 Reply Last reply
        0
        • F ForNow

          CAsyncSocket is a member of my CWinThread Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread Thanks

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          > Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread :zzz: Well where and how did Joe inform you about it?

          F 1 Reply Last reply
          0
          • V Victor Nijegorodov

            > Joe Newcomber informed that if I declared the CAsynsocket on the stack instead of the heap I will get notification thru the main thread :zzz: Well where and how did Joe inform you about it?

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            I sent him a e-mail earlier about the problem my workaround was to save the threadid before doing the connect After getting the notification I did a PostThread to the Thread did the connect Joe said that the reason this Happened (getting the notification to the Main Thread) Because I had declared my CAsynSocket Class on the Stack e.g. CAsynSocket mysocket. As opposed to the heap CAsynSocket *mysocket I haven't tried this out yet

            V 1 Reply Last reply
            0
            • F ForNow

              I sent him a e-mail earlier about the problem my workaround was to save the threadid before doing the connect After getting the notification I did a PostThread to the Thread did the connect Joe said that the reason this Happened (getting the notification to the Main Thread) Because I had declared my CAsynSocket Class on the Stack e.g. CAsynSocket mysocket. As opposed to the heap CAsynSocket *mysocket I haven't tried this out yet

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #6

              Your retelling of the Joe's reply is a little vague... But did you read his essays Detach[^] and KB192570: MFC Asynchronous Ports[^]?

              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