[gambit-list] Looking for a way to tell if a network port is still connected

Frederick LeMaster fred.lemaster at gmail.com
Tue Sep 15 16:39:13 EDT 2009


My current work around is to use the timeout thunk:
(define (add-input-check port check-interval check-proc)
    (letrec ((timeout (lambda ()
                                   (check-proc port)
                                   (input-port-timeout-set!
check-interval timeout)
                                   #t)))
        (input-port-timeout-set! port check-interval timeout)))

(add-input-check tcp-port 5 (lambda () (println 'timed-out-but-still-connected))
(if (eof-object? (read-line tcp-port))
    (close-port tcp-port))

If there's an easier way though, I'd love to hear about it.

On Mon, Sep 14, 2009 at 8:02 PM, Frederick LeMaster
<fred.lemaster at gmail.com> wrote:
> Is there a way to tell if a network port is still connected? If you
> try to read from a disconnected port, gambit returns an #eof. But if
> you set a timeout for a port it will also return #eof if the timeout
> expires. Is there a way to know for sure?
>



More information about the Gambit-list mailing list