[plt-scheme] timeout for read-line

From: ifconfig (ifconfignslookup at hotmail.com)
Date: Tue Feb 3 10:57:45 EST 2004

Here's a way to do it:
(there's probably a much easier way I don't know about though. This
hasn't been tested but should work).

(define (read-line-with-timeout timeout)
  (with-handlers ([exn:user? (lambda (e) #f)])
		; this returns #f on break or timeout.
    (let ([breaker (lambda (thread-to-break)
                     (sleep timeout)
                     (break thread-to-break))]
		; not sure this should be (break thread). If doesn't
work, check 		; the help files for breaking threads.
          [break-thread (thread (lambda () (breaker (current-thread))))]
          [result (read-line)])
      (kill-thread break-thread)
		; this is so it doesn't break after reading.
      result)))


-----Original Message-----
From: plt-scheme-admin at list.cs.brown.edu
[mailto:plt-scheme-admin at list.cs.brown.edu] On Behalf Of Vincent Hourdin
Sent: Tuesday, February 03, 2004 12:18 AM
To: plt-scheme at fast.cs.utah.edu
Subject: [plt-scheme] timeout for read-line

  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Hello,
is there a way to setup a timeout to (read-line) on a tcp input-port ?


Posted on the users mailing list.