X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-simple-streams%2Fsocket.lisp;h=b39fe67921b7a2ddad86fe16904f313d94a697b1;hb=fb8533122551bbb7aea669f40bc91c1211809b58;hp=d08cb17e237f4fa6955d5a3076955a57075d99c7;hpb=cc9a73604f696b6e69842a95b1e11f40f8cdd7bf;p=sbcl.git diff --git a/contrib/sb-simple-streams/socket.lisp b/contrib/sb-simple-streams/socket.lisp index d08cb17..b39fe67 100644 --- a/contrib/sb-simple-streams/socket.lisp +++ b/contrib/sb-simple-streams/socket.lisp @@ -20,6 +20,20 @@ (socket :initform nil :type (or sb-bsd-sockets:socket null) :initarg :socket))) +(defmethod print-object ((object socket-simple-stream) stream) + (print-unreadable-object (object stream :type nil :identity nil) + (with-stream-class (socket-simple-stream object) + (cond ((not (any-stream-instance-flags object :simple)) + (princ "Invalid " stream)) + ((not (any-stream-instance-flags object :input :output)) + (princ "Closed " stream))) + (format stream "~:(~A~)" + (type-of object)) + (when (any-stream-instance-flags object :input :output) + (multiple-value-bind (host port) + (sb-bsd-sockets:socket-peername (sm socket object)) + (format stream " connected to host ~S, port ~S" host port)))))) + (def-stream-class socket-base-simple-stream (dual-channel-simple-stream) ()) @@ -29,7 +43,7 @@ (socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp))) (unless (and remote-host remote-port) - (error "~S requires :remote-host and :remote-port arguments" + (error "device-open on ~S requires :remote-host and :remote-port arguments" 'socket-simple-stream)) (with-stream-class (socket-simple-stream stream) (ecase (getf options :direction :input)