chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Is there a way to get tcp-accept to time-out?


From: Ed Watkeys
Subject: [Chicken-users] Is there a way to get tcp-accept to time-out?
Date: Thu, 24 Feb 2005 19:58:01 -0500

Hi all,

Anyone know of a way to get tcp-accept to time-out? Or, barring that, is there a way I can get a file descriptor from a listener so I can call file-select with it?

tcp-accept could be re-written to look something like this:

(define (tcp-accept l . timeout)
  (let ((timeout (if (null? timeout) #f (car timeout))))
    (call-with-values
        (lambda ()
          (file-select (list (get-listener-fd l))
                       '()
                       timeout))
      (lambda (in out)
        (if (null? in)
            #f
            (old-tcp-accept l))))))

Why do I want to do this? In order to gracefully tear down a server without it hanging around to accept one last connection. In the past I've actually written servers that would open connections to themselves to get the last accept to let go, but I was playing with SISC and got spoiled by it's set-so-timeout! procedure (there thanks to its Java-ness.) Anyone have a suggestion?

Regards,
Ed





reply via email to

[Prev in Thread] Current Thread [Next in Thread]