Socket server timeouts (or: non-blocking io)

Help
2008-08-08
2012-12-07
  • Nobody/Anonymous

    Hi there,

    I had posted a year or so ago, I am still a fan of dclib, which is great to the bone ;-)

    Today, I ran into a small problem: I wanted to create a socket server (e.g. like your http server example), that does disconnect the client after some time, when no input is sent.
    (Example: start your http server example, then telnet localhost:5000 and type nothing). I tried all server interfaces you offer (with connections converted to streams) to somehow achieve non-blocking IO via iostream::readsome(), but it does not work, when no characters have been sent (e.g. a user connects via telnet and does nothing).

    Would it be hard to implement a method, that either returns a file descriptor (so I can call non-blocking select()), or offers some kind of timeout mechanism on the connection object itself?

    Thanks for your help and keep up the good work!
    Bye,
    Peter

     
    • Davis

      Davis - 2008-08-08

      Glad you still find it useful :)

      Have you looked at the timeout object?  http://dclib.sourceforge.net/dlib/timeout/timeout_kernel_abstract.h.html
      I think it might be what you are looking for.

      -Davis

       
    • Nobody/Anonymous

      Wow, thanks for the quick help, once again! The timeout object works flawlessly, great!

      (Just a small update to the example code snipplet in timeout_kernel_abstract.h:
      It should read timeout::kernel_1a t(...) instead of timeout t(...))

      I really love the library and the support you are giving! Thank you very much!

      Btw: your library works very clean when using tools like valgrind - in contrast to other libraries ;-)

      Best greetings from Germany,
      Peter

       
      • Davis

        Davis - 2008-08-10

        Thanks :)

        Let me know if you encounter any other issues with the library.

        Cheers,
        Davis

         

Log in to post a comment.