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. multi-threaded socket app

multi-threaded socket app

Scheduled Pinned Locked Moved C / C++ / MFC
beta-testingquestioncode-review
2 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.
  • R Offline
    R Offline
    Roman Nurik
    wrote on last edited by
    #1

    i want to make my own multi-thread socket classes (really really simple ones, so i can use them in my small games and such, and just to learn) i want to create a thread that will call select() and will allow for me to wait for feedback on a set of sockets however, i want to interrupt select() so that i can add sockets to the select list when the user calls AddSocket() how would i do that? i dont want to forcefully end the thread, nor do i want to create a thread per-socket hmm?

    r -€

    A 1 Reply Last reply
    0
    • R Roman Nurik

      i want to make my own multi-thread socket classes (really really simple ones, so i can use them in my small games and such, and just to learn) i want to create a thread that will call select() and will allow for me to wait for feedback on a set of sockets however, i want to interrupt select() so that i can add sockets to the select list when the user calls AddSocket() how would i do that? i dont want to forcefully end the thread, nor do i want to create a thread per-socket hmm?

      r -€

      A Offline
      A Offline
      Aaron Schaefer
      wrote on last edited by
      #2

      Well, I don't think you can interrupt select. But, if you want to start a thread to respond to socket events on a set of sockets, you may consider calling WSAEventSelect instead. Associate an event handle with each socket, register for events you are interested in with WSAEventSelect for each socket, then to wait for the events, call WSAWaitFormultipleEvents. The thing about this is that the array of event handles can include other events besides socket events. So, maybe the 0th event handle could be an event that another thread could use to signal the thread that is waiting for the sockets to do something else, like shutdown, or whatever else.

      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