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. Can Tcp/Ip "Accept() " Be Made "Non Blocking"

Can Tcp/Ip "Accept() " Be Made "Non Blocking"

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminquestion
7 Posts 6 Posters 1 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.
  • J Offline
    J Offline
    jerry1211a
    wrote on last edited by
    #1

    I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry

    R R P G 4 Replies Last reply
    0
    • J jerry1211a

      I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      I think you may instead want to call Listen() in a separate thread. Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted. See this[^] MSDN link. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      R 1 Reply Last reply
      0
      • J jerry1211a

        I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry

        R Offline
        R Offline
        Rickard Andersson20
        wrote on last edited by
        #3

        I think you should go by select() then. It takes a parameter which specifies a timeout for the operation. You can also check out the WSAAccept() function. Rickard Andersson Here is my card, contact me later! UIN: 50302279 Sonork: 37318

        1 Reply Last reply
        0
        • R Ravi Bhavnani

          I think you may instead want to call Listen() in a separate thread. Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted. See this[^] MSDN link. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          Ravi Bhavnani wrote: Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted. Actually, Listen() simply sets up the socket for accepting connections, and accepts the size of the connection backlog (how many connections can be queued before they are accepted using Accept()). Accept() is a blocking call that waits for a connection, and accepts it when one arrives.

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          R 1 Reply Last reply
          0
          • J jerry1211a

            I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry

            P Offline
            P Offline
            palbano
            wrote on last edited by
            #5

            For anyone learning Windows Sockets development: http://www.sockets.com/[^]

            "No matter where you go, there your are." - Buckaroo Banzai

            -pete

            1 Reply Last reply
            0
            • J jerry1211a

              I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry

              G Offline
              G Offline
              geo_m
              wrote on last edited by
              #6

              or if you don't worry about win9x stuff, you can look here around for some articles about IOCP.

              1 Reply Last reply
              0
              • R Ryan Binns

                Ravi Bhavnani wrote: Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted. Actually, Listen() simply sets up the socket for accepting connections, and accepts the size of the connection backlog (how many connections can be queued before they are accepted using Accept()). Accept() is a blocking call that waits for a connection, and accepts it when one arrives.

                Ryan

                "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                R Offline
                R Offline
                Ravi Bhavnani
                wrote on last edited by
                #7

                Sorry - my bad! :-O /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

                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