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. Winsock ? Again

Winsock ? Again

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++sysadmin
4 Posts 4 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.
  • S Offline
    S Offline
    Stan the man
    wrote on last edited by
    #1

    Hi. My previous question was whether I need the platform SDk for WInsock. I want to use WSA.., connect, etc type of calls instead of MFC ones. I assume the answer is still the same and I do not need the platform SDK. The next question I got is this. EACH port can only connect to ONE server. Is this correct? I want to write a client class that will connect to a server. It will then spawn a thread to handle the reading of the data as it comes so as to get the data as soon as possible. If only ONE connection is possible, then I can just use the event method to signal that data has come in. Is this the best way? THis way I know when things come in and when a write is finished if I need it. I don't think I will have too many clients on the computer so that creating a thread for each socket port is probably OK. I just want to make sure my thinking is along the right lines. THanks!!!

    A P P 3 Replies Last reply
    0
    • S Stan the man

      Hi. My previous question was whether I need the platform SDk for WInsock. I want to use WSA.., connect, etc type of calls instead of MFC ones. I assume the answer is still the same and I do not need the platform SDK. The next question I got is this. EACH port can only connect to ONE server. Is this correct? I want to write a client class that will connect to a server. It will then spawn a thread to handle the reading of the data as it comes so as to get the data as soon as possible. If only ONE connection is possible, then I can just use the event method to signal that data has come in. Is this the best way? THis way I know when things come in and when a write is finished if I need it. I don't think I will have too many clients on the computer so that creating a thread for each socket port is probably OK. I just want to make sure my thinking is along the right lines. THanks!!!

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      Each port can simultaneously connect to a single server, so that is correct. However, you can start a seperate thread which monitors ALL the open ports. Afterall, checking a port isn't a long process, so this shouldn't cause any timing issues. Now, instead of opening dozens of ports, I suggest that you formulate the data sent by the server, if that is possible. Place a identification number in front of each data packet to tell your program from which 'virtual port' this packet is coming from. This way you can open 'multiple' connections to a single server using only single physical port. The event driven method is appropriate, considering that you created a seperate thread to handle the port. Now, when a port event occurs, the handler thread is notified. At this point, save the data to a temporary variable, free the port and notify your application that new data is available. This way the port is freed quickly, but the transfer of data from the port to the application isn't in a terrible hurry. This is called data buffering. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      1 Reply Last reply
      0
      • S Stan the man

        Hi. My previous question was whether I need the platform SDk for WInsock. I want to use WSA.., connect, etc type of calls instead of MFC ones. I assume the answer is still the same and I do not need the platform SDK. The next question I got is this. EACH port can only connect to ONE server. Is this correct? I want to write a client class that will connect to a server. It will then spawn a thread to handle the reading of the data as it comes so as to get the data as soon as possible. If only ONE connection is possible, then I can just use the event method to signal that data has come in. Is this the best way? THis way I know when things come in and when a write is finished if I need it. I don't think I will have too many clients on the computer so that creating a thread for each socket port is probably OK. I just want to make sure my thinking is along the right lines. THanks!!!

        P Offline
        P Offline
        Pir8ofTampa
        wrote on last edited by
        #3

        Sorry, 'bout that, now I understand what you are asking. No you don't need SDK. Theoretically, constructing WsaData explicitly requires SockAddr_in struct but I had an instructor once who said that dynamic sockets are possible but never showed me how. Also, I've never tried to use a "Send" socket and a "Receive" socket (I assume this is what you are trying). I'll have to think more about this one using winsock2.

        1 Reply Last reply
        0
        • S Stan the man

          Hi. My previous question was whether I need the platform SDk for WInsock. I want to use WSA.., connect, etc type of calls instead of MFC ones. I assume the answer is still the same and I do not need the platform SDK. The next question I got is this. EACH port can only connect to ONE server. Is this correct? I want to write a client class that will connect to a server. It will then spawn a thread to handle the reading of the data as it comes so as to get the data as soon as possible. If only ONE connection is possible, then I can just use the event method to signal that data has come in. Is this the best way? THis way I know when things come in and when a write is finished if I need it. I don't think I will have too many clients on the computer so that creating a thread for each socket port is probably OK. I just want to make sure my thinking is along the right lines. THanks!!!

          P Offline
          P Offline
          Peter Molnar
          wrote on last edited by
          #4

          Stan the man wrote: EACH port can only connect to ONE server. Is this correct? 1. Yes, but only if you use TCP, because it is connection oriented. 2. No, if use UDP datagramms. Datagramms are "broadcasted" therefore they can have several recipients. Bunburry

          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