[racket] How to wait for tcp-accpt-evt unless the listener is or has been closed?

From: Erich Rast (erich at snafu.de)
Date: Thu Sep 13 16:02:40 EDT 2012

> 
> A simpler possibility is to use a custodian 

I've tried a custodian and it worked fine. But then I've
figured out that a simple exception handler also works, 
and in this case it has the advantage that the finalize-proc called at
the end of my file transfer will terminate gracefully.

  (define (accept-connection/maybe listener)
    (with-handlers ([exn:fail:network? (lambda (exn) #f)])
      (sync/enable-break (tcp-accept-evt listener))))
 
In either case the problem is solved. Thanks a lot!

Best,

Erich

Posted on the users mailing list.