Paste number 152828: failure to read

Index of paste annotations: 1

Paste number 152828: failure to read
Pasted by: bvulpes
When:5 years, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+39X8
Channel:None
Paste contents:
Raw Source | XML | Display As
(defun read-message (stream)
  (let* ((magic (make-array 4))
         (command (make-array 12))
         (size (make-array 4))
         (checksum (make-array 4)))
    (read-sequence magic stream)
    ;; (read-sequence command stream)
    (dotimes (i 12 t)
      (push (read-char stream) command))
    (read-sequence size stream)
    (read-sequence checksum stream)
    (format t "~a" command)))

(defun read-write-and-close ()
  (let* ((sock
          (usocket:socket-connect "localhost" 8333 :element-type '(unsigned-byte 8))))
    (write-command "version"
                   (make-version-message)
                   'write-version-message
                   (usocket:socket-stream sock))
    (read-message (usocket:socket-stream sock))
    (usocket:socket-close sock)))

Annotations for this paste:

Annotation number 1: failure to read characters
Pasted by: bvulpes
When:5 years, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+39X8/1
Paste contents:
Raw Source | Display As
(defun read-message (stream)
  (let* ((magic (make-array 4))
         (command (make-array 12))
         (size (make-array 4))
         (checksum (make-array 4)))
    (read-sequence magic stream)
    (read-sequence command stream)
    (read-sequence size stream)
    (read-sequence checksum stream)
    (format t "~a" command)))

(defun read-write-and-close ()
  (let* ((sock
          (usocket:socket-connect "localhost" 8333 :element-type '(unsigned-byte 8))))
    (write-command "version"
                   (make-version-message)
                   'write-version-message
                   (usocket:socket-stream sock))
    (read-message (usocket:socket-stream sock))
    (usocket:socket-close sock)))

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.