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. Sockets without MFC/HWNDs or Spin-Locks?

Sockets without MFC/HWNDs or Spin-Locks?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
3 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.
  • P Offline
    P Offline
    Phil Speller
    wrote on last edited by
    #1

    MFC's ASyncSocket class provides a wrapper around a Win32 socket and adds functionality to detect events (such as connection, packet received etc). Now I'm aware that a similar method can be performed using plain winsock programming and the use of WSAAsyncSelect. However, it requires the use of a window to receive events (CAsyncSocket does it like this as well doesn't it?). I've seen code that sets up a thread and just waits on recv() using a spin-lock - this seems to go against the grain with me though. I have noticed the select() fn, but I'm not sure if it would truly be thread friendly or would just hide a spin-lock. So, to my question: Is it possible to detect an event from a Socket without resorting to window messages or requiring a spin-lock? Phil

    S J 2 Replies Last reply
    0
    • P Phil Speller

      MFC's ASyncSocket class provides a wrapper around a Win32 socket and adds functionality to detect events (such as connection, packet received etc). Now I'm aware that a similar method can be performed using plain winsock programming and the use of WSAAsyncSelect. However, it requires the use of a window to receive events (CAsyncSocket does it like this as well doesn't it?). I've seen code that sets up a thread and just waits on recv() using a spin-lock - this seems to go against the grain with me though. I have noticed the select() fn, but I'm not sure if it would truly be thread friendly or would just hide a spin-lock. So, to my question: Is it possible to detect an event from a Socket without resorting to window messages or requiring a spin-lock? Phil

      S Offline
      S Offline
      Stephane Rodriguez
      wrote on last edited by
      #2

      A website[^] you'll love.


      How low can you go ?
      (MS rant)

      1 Reply Last reply
      0
      • P Phil Speller

        MFC's ASyncSocket class provides a wrapper around a Win32 socket and adds functionality to detect events (such as connection, packet received etc). Now I'm aware that a similar method can be performed using plain winsock programming and the use of WSAAsyncSelect. However, it requires the use of a window to receive events (CAsyncSocket does it like this as well doesn't it?). I've seen code that sets up a thread and just waits on recv() using a spin-lock - this seems to go against the grain with me though. I have noticed the select() fn, but I'm not sure if it would truly be thread friendly or would just hide a spin-lock. So, to my question: Is it possible to detect an event from a Socket without resorting to window messages or requiring a spin-lock? Phil

        J Offline
        J Offline
        JT Anderson
        wrote on last edited by
        #3

        You might find WSAEventSelect interesting. -------- There are 10 types of people in this world. Those who know binary and those who don't.

        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