X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-bsd-sockets%2Fmisc.lisp;h=21ce4866b819d1a29298f8cc2ec96fca1bdd8d0c;hb=92c8db80e039f60623e53a0b9355cf0a9ec49f3d;hp=6dd2bfbfe27c1424ae2430e87dba2b33daacc697;hpb=10d2c05ea44ca0837091434fe2223c0c31687615;p=sbcl.git diff --git a/contrib/sb-bsd-sockets/misc.lisp b/contrib/sb-bsd-sockets/misc.lisp index 6dd2bfb..21ce486 100644 --- a/contrib/sb-bsd-sockets/misc.lisp +++ b/contrib/sb-bsd-sockets/misc.lisp @@ -9,8 +9,10 @@ ;;; XXX bad (sizeof (int) ==4 ) assumptions +(defgeneric non-blocking-mode (socket) + (:documentation "Is SOCKET in non-blocking mode?")) + (defmethod non-blocking-mode ((socket socket)) - "Is SOCKET in non-blocking mode?" (let ((fd (socket-file-descriptor socket))) (sb-alien:with-alien ((arg integer)) (> (logand @@ -18,8 +20,10 @@ sockint::o-nonblock) 0)))) +(defgeneric (setf non-blocking-mode) (non-blocking-p socket) + (:documentation "Put SOCKET in non-blocking mode - or not, according to NON-BLOCKING-P")) + (defmethod (setf non-blocking-mode) (non-blocking-p (socket socket)) - "Put SOCKET in non-blocking mode - or not, according to NON-BLOCKING-P" (declare (optimize (speed 3))) (let* ((fd (socket-file-descriptor socket)) (arg1 (the (signed-byte 32) (sockint::fcntl fd sockint::f-getfl 0))) @@ -28,7 +32,7 @@ (logior arg1 sockint::o-nonblock) (logand (lognot sockint::o-nonblock) arg1)))) (when (= (the (signed-byte 32) -1) - (the (signed-byte 32) + (the (signed-byte 32) (sockint::fcntl fd sockint::f-setfl arg2))) (socket-error "fcntl")) non-blocking-p))