sb-bsd-sockets: GET-ADDRESS-INFO foreign memory leak
[sbcl.git] / contrib / sb-bsd-sockets / misc.lisp
index 6dd2bfb..2c0246b 100644 (file)
@@ -9,8 +9,11 @@
 
 ;;; XXX bad (sizeof (int) ==4 ) assumptions
 
+(defgeneric non-blocking-mode (socket)
+  (:documentation "Is SOCKET in non-blocking mode?"))
+
+#-win32
 (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
                              sockint::o-nonblock)
                             0))))
 
+#+win32
+(defmethod non-blocking-mode ((socket socket)) 0)
+
+(defgeneric (setf non-blocking-mode) (non-blocking-p socket)
+  (:documentation "Put SOCKET in non-blocking mode - or not, according to NON-BLOCKING-P"))
+
+#-win32
 (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)))
               (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))
 
+#+win32
+(defmethod (setf non-blocking-mode) (non-blocking-p (socket socket)) 0)
+;;  (sb-alien:with-alien ((mode (unsigned 32)))
+;;    (if non-blocking-p (setf mode 1))
+;;       (ioctlsocket socket FIONBIO mode)))