;; curl gopher://gopher.black returns some more items ;; the code below does not read all available data before the connection is closed by the remote end (use extras tcp) (define (request-resource server #!optional (resource index) (port gopher-port) until-eof?) (printf "Connecting to ~a:~a ~a " server port resource) (condition-case (let-values (((i o) (tcp-connect server port))) (print "co(use extras tcp) nnected.") (display (string-append resource (string #\linefeed #\return)) o) (flush-output o) (let ((response (butlast (read-lines i)))) (close-input-port i) (close-output-port o) response)) (e (exn i/o net) (print "Network error: ~a" ((condition-property-accessor 'exn 'message) e)) (sleep 1)) (e () (pp (condition->list e)) (abort e)))) (pp (request-resource "gopher.black" "/" 70))(define (request-resource server #!optional (resource index) (port gopher-port) until-eof?) (printf "Connecting to ~a:~a ~a " server port resource) (condition-case (let-values (((i o) (tcp-connect server port))) (print "connected.") (display (string-append resource (string #\linefeed #\return)) o) (flush-output o) (let ((response (butlast (read-lines i)))) (close-input-port i) (close-output-port o) response)) (e (exn i/o net) (print "Network error: ~a" ((condition-property-accessor 'exn 'message) e)) (sleep 1)) (e () (pp (condition->list e)) (abort e))))