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 problem.

Winsock problem.

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelp
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.
  • D Offline
    D Offline
    Deepak Samuel
    wrote on last edited by
    #1

    Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.

    D T A 3 Replies Last reply
    0
    • D Deepak Samuel

      Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Use accept(). I had a little server application that used the following functions:

      WSAStartup()
      socket()
      bind()
      listen()
      accept() in loop
      closesocket()
      WSACleanup()


      "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

      1 Reply Last reply
      0
      • D Deepak Samuel

        Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.

        T Offline
        T Offline
        Timothy Grabrian
        wrote on last edited by
        #3

        If you want to wade through some stuff, this link http://www.vijaymukhi.com/vmis/vmchap4.htm should show you an easier way using winsock 2 (that won't freeze your application). wWw.KruncherInc.cOm

        1 Reply Last reply
        0
        • D Deepak Samuel

          Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.

          A Offline
          A Offline
          Alexander M
          wrote on last edited by
          #4

          what kind of sockets are you using? TCP or UDP? There are 4 (as far as I know) ways to get informed about incoming data. these ways are: - blocking sockets (call recv() and what till it returns control to your app) - use select() to check whether there is activity on the socket - use WSAEventSelect() to assign an EVENT to a socket and then wait for the event - use WSAAsyncSelect() to make the socket send window messages when there is activity If you want to create a server which has a main window, then the forth way could be interesting. If your server doesn't have a window: - For servers (TCP) with only few clients or UDP servers you should use way one. - For servers (TCP) with many clients I'd prefer way two (It's also linux compatible :)). I hope I could help.... Don't try it, just do it! ;-)

          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