SERVE-EVENT now allows streams and sockets as arguments, instead of file descriptors.

This commit is contained in:
Juan Jose Garcia Ripoll 2010-02-22 15:11:41 +01:00
parent cf315df2c6
commit dacffdc468
2 changed files with 13 additions and 1 deletions

View file

@ -56,11 +56,20 @@
(define-c-constants
+eintr+ "EINTR")
(defmethod ext::stream-fd ((stream t))
(etypecase stream
(fixnum stream)
(two-way-stream (ext::stream-fd (two-way-stream-input-stream stream)))
(file-stream (si:file-stream-fd stream))
(otherwise (error "In SERVE-EVENT, stream~% ~A~%does not have an associated file descriptor" stream))))
(defstruct (handler
(:constructor make-handler (direction descriptor function))
(:constructor make-handler (direction stream-or-descriptor function
&aux (descriptor (ext::stream-fd stream-or-descriptor))))
(:copier nil))
;; Reading or writing...
(direction nil :type (member :input :output))
(stream-or-descriptor nil)
;; File descriptor this handler is tied to.
;; FIXME: Should be based on FD_SETSIZE
(descriptor 0)

View file

@ -1236,6 +1236,9 @@ also known as unix-domain sockets."))
(sb-ext:cancel-finalization socket))
stream))
(defmethod ext::stream-fd ((socket socket))
(socket-file-descriptor socket))
#+:wsock
(defmethod socket-make-stream ((socket named-pipe-socket)
&key input output