X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-bsd-sockets%2Fsockets.lisp;h=8cf96d5b97901827ad6e400632ae7854ee1204d2;hb=a7699535aaba71765335f3be0a2103b2f07941af;hp=9118a6ad805a76a7bf0d0b448ba5fea849182ac7;hpb=7254da92a1ba1bf8bc5a2e78a29d993f272d526e;p=sbcl.git diff --git a/contrib/sb-bsd-sockets/sockets.lisp b/contrib/sb-bsd-sockets/sockets.lisp index 9118a6a..8cf96d5 100644 --- a/contrib/sb-bsd-sockets/sockets.lisp +++ b/contrib/sb-bsd-sockets/sockets.lisp @@ -26,6 +26,8 @@ protocol. Other values are used as-is.") (type :initarg :type :reader socket-type :documentation "Type of the socket: :STREAM or :DATAGRAM.") + #+win32 + (non-blocking-p :type (member t nil) :initform nil) (stream)) (:documentation "Common base class of all sockets, not meant to be directly instantiated."))) @@ -229,7 +231,7 @@ buffer was too small.")) (list sockint::EAGAIN sockint::EINTR))) nil) ((= len -1) (socket-error "recvfrom")) - (t (loop for i from 0 below len + (t (loop for i from 0 below (min len length) do (setf (elt buffer i) (cond ((or (eql element-type 'character) (eql element-type 'base-char)) @@ -374,6 +376,24 @@ Otherwise closes the socket file descriptor using close(2).")) (declare (ignore r)) (drop-it)))))))) +(defgeneric socket-shutdown (socket &key direction) + (:documentation + "Indicate that no communication in DIRECTION will be performed on SOCKET. + +DIRECTION has to be one of :INPUT, :OUTPUT or :IO. + +After a shutdown, no input and/or output of the indicated DIRECTION +can be performed on SOCKET.")) + +(defmethod socket-shutdown ((socket socket) &key direction) + (let* ((fd (socket-file-descriptor socket)) + (how (ecase direction + (:input sockint::SHUT_RD) + (:output sockint::SHUT_WR) + (:io sockint::SHUT_RDWR)))) + (when (minusp (sockint::shutdown fd how)) + (socket-error "shutdown")))) + (defgeneric socket-make-stream (socket &key input output element-type external-format buffering @@ -433,7 +453,7 @@ request an input stream and get an output stream in response\)." :external-format external-format :timeout timeout :auto-close auto-close - :serve-events serve-events)) + :serve-events (and serve-events #+win32 nil))) (setf (slot-value socket 'stream) stream)) (sb-ext:cancel-finalization socket) stream)) @@ -454,7 +474,9 @@ request an input stream and get an output stream in response\)." (socket-error-syscall c) (or (socket-error-symbol c) (socket-error-errno c)) #+cmu (sb-unix:get-unix-error-msg num) - #+sbcl (sb-int:strerror num))))) + #+sbcl + #+win32 (sb-win32::get-last-error-message num) + #-win32 (sb-int:strerror num))))) (:documentation "Common base class of socket related conditions.")) ;;; watch out for slightly hacky symbol punning: we use both the value