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. CAsynSocket Client Question

CAsynSocket Client Question

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 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 want to connect a number of sockets (2 or 3) on a port seems like the underlying Object of CAsynSocket is m_hSocket. That would lead me to believe that on the Client Side for Every Client m_hSocket I would have to instantiate a CAsnycSocket class via new (on the heap) and do a Create and later connect ? It seems after the Create m_hSocket would have a value am I correct on this ? Thanks

    Richard Andrew x64R V 2 Replies Last reply
    0
    • F ForNow

      Hi I want to connect a number of sockets (2 or 3) on a port seems like the underlying Object of CAsynSocket is m_hSocket. That would lead me to believe that on the Client Side for Every Client m_hSocket I would have to instantiate a CAsnycSocket class via new (on the heap) and do a Create and later connect ? It seems after the Create m_hSocket would have a value am I correct on this ? Thanks

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      It's not completely clear what you're asking, but I can say that m_hSocket is the underlying SOCKET handle that the CAsyncSocket object encapsulates. You are able to create a new CAsyncSocket object and then attach an existing SOCKET handle by using the Attach() method.

      The difficult we do right away... ...the impossible takes slightly longer.

      F 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        It's not completely clear what you're asking, but I can say that m_hSocket is the underlying SOCKET handle that the CAsyncSocket object encapsulates. You are able to create a new CAsyncSocket object and then attach an existing SOCKET handle by using the Attach() method.

        The difficult we do right away... ...the impossible takes slightly longer.

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

        Yes that's what I was looking for so if I want to use 2 Different sockets I have to have two instances of CAsynSocket In Addition If a wrapping CasynSockets in CWinThread Class when getting the OnConnect Notifcation Its is in The Context of the Main Thread so I would have to take that (Main Threads) m_hScoket and Attach to the one used by my CwinThread ? correct As I believe all CasynSocket notification are in the Context of the Main Thread Thanks

        1 Reply Last reply
        0
        • F ForNow

          Hi I want to connect a number of sockets (2 or 3) on a port seems like the underlying Object of CAsynSocket is m_hSocket. That would lead me to believe that on the Client Side for Every Client m_hSocket I would have to instantiate a CAsnycSocket class via new (on the heap) and do a Create and later connect ? It seems after the Create m_hSocket would have a value am I correct on this ? Thanks

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

          You may want to read this great Joe Newcommer essay: [An MFC Asynchronous Socket Example Done Right](http://www.flounder.com/kb192570.htm)

          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