[racket] tcp-read handlers

From: Eduardo Bellani (ebellani at gmail.com)
Date: Sat Jan 18 06:50:15 EST 2014

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there a way to install a handler for the tcp-error exception?
I have a function like this

(define (get-page link-url (max-tries 5))
  (let loop ([current-try 0])
    (with-handlers ([exn?
                     (? (e)
                        (if (> current-try max-tries)
                            (error 'get-page
                                   "failed because it exceeded ~a tries"
                                   max-tries)
                            (begin (sleep 2)
                                   (loop (add1 current-try)))))])
      (get-pure-port link-url))))

that I'm using to crawl some data, but sometimes it's printing:

tcp-read: error reading
  system error: Connection reset by peer; errno=104
  context...:
   /usr/racket/collects/net/url.rkt:392:3

Thanks for the attention.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlLaanUACgkQSbLl0kCTjGkm+ACbBSMyUuY4NOYjdLMgba/OJAFc
8OYAn0NkLMKLLma/MxAeEFMLtnrMekOY
=aAUJ
-----END PGP SIGNATURE-----

Posted on the users mailing list.