The documentation for make-http-connection indicates that the same connection can be reused repeatedly, unfortunately, this does not seem to work.
https://docs.racket-lang.org/net/url.html?q=make-http-connection#%28def._%28%28lib._net%2Furl..rkt%29._make-http-connection%29%29 Here is an example program: #lang racket (require net/url net/url-connect net/head) (define (tile->osm-url zoom x y) (string->url (format "https://tile.openstreetmap.org/~a/~a/~a.png" zoom x y))) (define user-agent "racket") (define (run-test download-count) (parameterize ((current-https-protocol 'secure)) (let ((connection (make-http-connection))) (for ([try (in-range 1 download-count)]) (printf "download ~a..." url)(flush-output) (define-values (port headers) (get-pure-port/headers (tile->osm-url 14 try 1) (list user-agent) #:connection connection)) (define content-type (extract-field "Content-Type" headers)) (define data (port->bytes port)) (unless (equal? content-type "image/png") (printf "expected a PNG image~%")) (printf " done.~%")(flush-output) ;; discard the data and start a new loop ) (http-connection-close connection)))) (run-test 1000) If you run the above program and monitor the racket process (I used procexp.exe on Windows, but you can use lsof on Linux), you'll notice that each request creates a separate socket connection, rather than reusing it, and these connections hang around for a long time before being closed. Is this a bug in make-http-connection and/or get-pure-port/headers, or am I using it incorrectly in the example above? This was noticed by someone on my map-widget package, and switching to `http-easy` solved the immediate problem (thanks Bogdan for that package!), but I thought I will ask here anyway, in case this is a bug. Thanks, Alex. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/825d24ac-ddb6-40ef-8101-dc85982addfdn%40googlegroups.com.