(in-package :cl-user) ;; User API functions (defun read-byte-no-hang (stream &optional eof-error-p eof-value) (let ((byte (stream-read-byte-no-hang stream))) (cond ((eq ':eof byte) (if eof-error-p (error 'end-of-file :stream stream) eof-value)) (t byte)))) #+CCL (defmethod stream-read-byte-no-hang (stream) (ccl:with-input-timeout ((stream) 0) (handler-case (read-byte stream nil :eof) (ccl:input-timeout () nil)))) #+SBCL (defmethod stream-read-byte-no-hang (input-stream) (sb-sys:with-deadline (:seconds 0) (handler-case (read-byte input-stream nil :eof) (sb-sys:deadline-timeout () nil))))