Author: ehuelsmann Date: Thu Dec 21 17:53:28 2006 New Revision: 131
Modified: trivial-usocket/trunk/trivial-usocket.lisp usocket/trunk/backend/allegro.lisp usocket/trunk/backend/armedbear.lisp usocket/trunk/backend/clisp.lisp usocket/trunk/backend/cmucl.lisp usocket/trunk/backend/lispworks.lisp usocket/trunk/backend/openmcl.lisp usocket/trunk/backend/sbcl.lisp usocket/trunk/backend/scl.lisp Log: Add support for the 'element-type' stream creation argument.
Modified: trivial-usocket/trunk/trivial-usocket.lisp ============================================================================== --- trivial-usocket/trunk/trivial-usocket.lisp (original) +++ trivial-usocket/trunk/trivial-usocket.lisp Thu Dec 21 17:53:28 2006 @@ -163,8 +163,6 @@ (error 'unsupported :feature :bind)) (unless (eql external-format :default) (error 'unsupported :feature :external-format)) - (unless (eql element-type 'character) - (error 'unsupported :feature :element-type)) (let ((socket (socket-connect peer-host peer-port))) (wrap-usocket-stream socket)))
Modified: usocket/trunk/backend/allegro.lisp ============================================================================== --- usocket/trunk/backend/allegro.lisp (original) +++ usocket/trunk/backend/allegro.lisp Thu Dec 21 17:53:28 2006 @@ -36,12 +36,14 @@ :real-error condition :socket socket))))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character) (let ((socket)) (setf socket (with-mapped-conditions (socket) (socket:make-socket :remote-host (host-to-hostname host) - :remote-port port))) + :remote-port port + :format (if (subtypep element-type 'character) + :text :binary)))) (make-stream-socket :socket socket :stream socket)))
(defmethod socket-close ((usocket usocket))
Modified: usocket/trunk/backend/armedbear.lisp ============================================================================== --- usocket/trunk/backend/armedbear.lisp (original) +++ usocket/trunk/backend/armedbear.lisp Thu Dec 21 17:53:28 2006 @@ -11,13 +11,15 @@ (typecase condition (error (error 'unknown-error :socket socket :real-error condition))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (let ((usock)) (with-mapped-conditions (usock) (let ((sock (ext:make-socket (host-to-hostname host) port))) (setf usock - (make-stream-socket :socket sock - :stream (ext:get-socket-stream sock))))))) + (make-stream-socket + :socket sock + :stream (ext:get-socket-stream sock + :element-type element-type)))))))
(defmethod socket-close ((usocket usocket)) (with-mapped-conditions (usocket)
Modified: usocket/trunk/backend/clisp.lisp ============================================================================== --- usocket/trunk/backend/clisp.lisp (original) +++ usocket/trunk/backend/clisp.lisp Thu Dec 21 17:53:28 2006 @@ -38,13 +38,13 @@ :socket socket :real-error condition))))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (let ((socket) (hostname (host-to-hostname host))) (with-mapped-conditions (socket) (setf socket (socket:socket-connect port hostname - :element-type 'character + :element-type element-type :buffered t))) (make-stream-socket :socket socket :stream socket))) ;; the socket is a stream too
Modified: usocket/trunk/backend/cmucl.lisp ============================================================================== --- usocket/trunk/backend/cmucl.lisp (original) +++ usocket/trunk/backend/cmucl.lisp Thu Dec 21 17:53:28 2006 @@ -53,14 +53,14 @@ :real-condition condition :socket socket))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (let* ((socket)) (setf socket (with-mapped-conditions (socket) (ext:connect-to-inet-socket (host-to-hbo host) port :stream))) (if socket (let* ((stream (sys:make-fd-stream socket :input t :output t - :element-type 'character + :element-type element-type :buffering :full)) ;;###FIXME the above line probably needs an :external-format (usocket (make-stream-socket :socket socket
Modified: usocket/trunk/backend/lispworks.lisp ============================================================================== --- usocket/trunk/backend/lispworks.lisp (original) +++ usocket/trunk/backend/lispworks.lisp Thu Dec 21 17:53:28 2006 @@ -47,12 +47,13 @@ ;; :real-condition condition ;; :socket socket))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (let ((hostname (host-to-hostname host)) (stream)) (setf stream (with-mapped-conditions () - (comm:open-tcp-stream hostname port))) + (comm:open-tcp-stream hostname port + :element-type element-type))) (if stream (make-stream-socket :socket (comm:socket-stream-socket stream) :stream stream)
Modified: usocket/trunk/backend/openmcl.lisp ============================================================================== --- usocket/trunk/backend/openmcl.lisp (original) +++ usocket/trunk/backend/openmcl.lisp Thu Dec 21 17:53:28 2006 @@ -40,12 +40,15 @@ (error (error 'unknown-error :socket socket :real-error condition)) (condition (signal 'unknown-condition :real-condition condition))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (with-mapped-conditions () (let ((mcl-sock (openmcl-socket:make-socket :remote-host (host-to-hostname host) :remote-port port))) - (openmcl-socket:socket-connect mcl-sock) + (openmcl-socket:socket-connect mcl-sock + :element-type (if (subtypep element-type + 'character) + :text :binary)) (make-stream-socket :stream mcl-sock :socket mcl-sock))))
(defmethod socket-close ((usocket usocket))
Modified: usocket/trunk/backend/sbcl.lisp ============================================================================== --- usocket/trunk/backend/sbcl.lisp (original) +++ usocket/trunk/backend/sbcl.lisp Thu Dec 21 17:53:28 2006 @@ -59,14 +59,14 @@ :real-condition condition))))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (let* ((socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream :protocol :tcp)) (stream (sb-bsd-sockets:socket-make-stream socket :input t :output t :buffering :full - :element-type 'character)) + :element-type element-type)) ;;###FIXME: The above line probably needs an :external-format (usocket (make-stream-socket :stream stream :socket socket)) (ip (host-to-vector-quad host)))
Modified: usocket/trunk/backend/scl.lisp ============================================================================== --- usocket/trunk/backend/scl.lisp (original) +++ usocket/trunk/backend/scl.lisp Thu Dec 21 17:53:28 2006 @@ -33,12 +33,12 @@ :real-condition condition :socket socket))))
-(defun socket-connect (host port) +(defun socket-connect (host port &key (element-type 'character)) (let* ((socket (with-mapped-conditions (nil) (ext:connect-to-inet-socket (host-to-hbo host) port :kind :stream))) (stream (sys:make-fd-stream socket :input t :output t - :element-type 'character + :element-type element-type :buffering :full))) ;;###FIXME the above line probably needs an :external-format (make-stream-socket :socket socket :stream stream)))