Welcome to the CHICKEN Scheme pasting service

This code does not get all data... pasted by C-Keen on Fri Apr 27 12:27:35 2018

;; 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))))

There are typos and there are pastos.. pasted by C-Keen on Fri Apr 27 13:08:56 2018

(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 "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))))

(pp (request-resource "gopher.black" "/" 70))

strace of the run added by C-Keen on Fri Apr 27 13:14:32 2018

write(1, "Connecting to gopher.black:70 / "..., 43) = 43
sendto(3, "/\n\r", 3, 0, NULL, 0)       = 3
recvfrom(3, 0x7ffc574ee168, 4096, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}], 1, 60000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "i                     |         "..., 4096, 0, NULL, NULL) = 73
recvfrom(3, 0x7ffc574ee168, 4096, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}], 1, 60000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "i       _` |  _ \\ _ \\   \\   -_) "..., 4096, 0, NULL, NULL) = 996
recvfrom(3, "", 4096, 0, NULL, NULL)    = 0
recvfrom(3, "", 4096, 0, NULL, NULL)    = 0
shutdown(3, SHUT_RD)                    = 0
shutdown(3, SHUT_WR)                    = 0
close(3)                                = 0
write(1, "(\"i                     |       "..., 78) = 78
write(1, " \"i       _` |  _ \\\\ _ \\\\   \\\\  "..., 84) = 84
write(1, " \"i     \\\\__, |\\\\___/.__/_| _|\\\\"..., 87) = 87
write(1, " \"i     ____/     _|\\t\\tgopher.b"..., 42) = 42
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"i     ==== Last Updated: April"..., 70) = 70
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"1About\\t/about\\tgopher.black\\t"..., 36) = 36
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"i==== Content ====\\t\\tgopher.b"..., 42) = 42
write(1, " \"1Phlog\\t/phlog\\tgopher.black\\t"..., 36) = 36
write(1, " \"1Writing\\t/writing\\tgopher.bla"..., 40) = 40
write(1, " \"1Explorations\\t/explorations\\t"..., 50) = 50
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"1Recipes\\t/recipebox\\tgopher.b"..., 42) = 42
write(1, " \"1Games\\t/games\\tgopher.black\\t"..., 36) = 36
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"i==== Resources ====\\t\\tgopher"..., 44) = 44
write(1, " \"1The Bible (ESV)\\t/bible\\tgoph"..., 46) = 46
write(1, " \"1Archives\\t/archive\\tgopher.bl"..., 41) = 41
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"i==== Books ====\\t\\tgopher.bla"..., 40) = 40
write(1, " \"0Reading\\t/reading/currentbook"..., 57) = 57
write(1, " \"0Read\\t/reading/recentbooks.tx"..., 53) = 53
write(1, " \"i\\t\\tgopher.black\\t70\"\n", 25) = 25
write(1, " \"i==== Software and Tech Things"..., 60) = 60
getrusage(RUSAGE_SELF, {ru_utime={tv_sec=0, tv_usec=4000}, ru_stime={tv_sec=0, tv_usec=8000}, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={tv_sec=0, tv_usec=4000}, ru_stime={tv_sec=0, tv_usec=8000}, ...}) = 0
close(2)                                = 0
exit_group(0)                           = ?
+

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the one-argument procedure to check if a list is empty?
Visually impaired? Let me spell it for you (wav file) download WAV