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. Aborting a socket accept() after X seconds

Aborting a socket accept() after X seconds

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadmindata-structures
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.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    Hello Is it possible to abort a socket accept after X seconds? I got two classes: cfiletransferserver and cfiletransferclient. I launch a cfiletransferserver on a specific port and than send the port to my client application. The client application then tries to connect to the server by using cfiletransferclient. cfiletransferserver deletes itself from the stack when the filetransfer is finished. I want cfiletransferserver to delete itself if no cfiletransferclient have connected to it in X seconds. How do I do that? Thanks, Jonas

    R 1 Reply Last reply
    0
    • J justin223

      Hello Is it possible to abort a socket accept after X seconds? I got two classes: cfiletransferserver and cfiletransferclient. I launch a cfiletransferserver on a specific port and than send the port to my client application. The client application then tries to connect to the server by using cfiletransferclient. cfiletransferserver deletes itself from the stack when the filetransfer is finished. I want cfiletransferserver to delete itself if no cfiletransferclient have connected to it in X seconds. How do I do that? Thanks, Jonas

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

      Instead of calling accept() for the listening socket, call select(). Select will block the thread until an event happens on the socket, ie. a connection is ready. The second parameter of the select() function is a TIMEVAL structure which can specify a timeout. The return value of the select() call specifies whether a timeout occurred or a connection was receivied, ready to accept using accept(). Look at the docs for more info. Hope this helps Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
      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"

      J 1 Reply Last reply
      0
      • R Ryan Binns

        Instead of calling accept() for the listening socket, call select(). Select will block the thread until an event happens on the socket, ie. a connection is ready. The second parameter of the select() function is a TIMEVAL structure which can specify a timeout. The return value of the select() call specifies whether a timeout occurred or a connection was receivied, ready to accept using accept(). Look at the docs for more info. Hope this helps Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
        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"

        J Offline
        J Offline
        jgauffin
        wrote on last edited by
        #3

        just what I was looking for! thanks!:)

        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