# Pastebin PHHt4I89 (defun recv-string-or-array-bytes (socket &key dontwait (encoding cffi:*default-foreign-encoding*)) "Receive a message part from a socket as a string." (pzmq:with-message msg (pzmq:msg-recv msg socket :dontwait dontwait) (values (let* ((data (pzmq:msg-data msg)) (len (pzmq:msg-size msg)) (all-graphic-p (loop for index from 0 below len always (graphic-char-p (cffi:mem-aref data :uint8 index))))) (if all-graphic-p (cffi:foreign-string-to-lisp data :count len :encoding encoding) (let ((array-bytes (make-array len :element-type 'ext:byte8))) (loop for index from 0 below len do (setf (aref array-bytes index) (cffi:mem-aref data :uint8 index))) array-bytes))) (pzmq:getsockopt socket :rcvmore))))