Changeset 12413


Ignore:
Timestamp:
Jul 14, 2009, 10:20:36 PM (10 years ago)
Author:
gz
Message:

add a :stream-args argument to accept-connection, for one-time initargs for the stream being created. E.g. (accept-connection listener :stream-args `(:external-format ,external-format-for-this-connection))

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-sockets.lisp

    r12301 r12413  
    896896                (set-socket-fd-blocking fd was-blocking)))))))
    897897
    898 (defun accept-socket-connection (socket wait stream-create-function)
     898(defun accept-socket-connection (socket wait stream-create-function &optional stream-args)
    899899  (let ((listen-fd (socket-device socket))
    900900        (fd -1))
    901901    (unwind-protect
    902       (progn
     902      (let ((keys (append stream-args (socket-keys socket))))
    903903        (setq fd (socket-accept listen-fd wait))
    904904        (cond ((>= fd 0)
    905                (prog1 (apply stream-create-function fd (socket-keys socket))
     905               (prog1 (apply stream-create-function fd keys)
    906906                 (setq fd -1)))
    907907              ((eql fd (- #$EAGAIN)) nil)
     
    910910        (fd-close fd)))))
    911911
    912 (defgeneric accept-connection (socket &key wait)
     912(defgeneric accept-connection (socket &key wait stream-args)
    913913  (:documentation
    914914  "Extract the first connection on the queue of pending connections,
     
    916916tcp-stream or file-socket-stream representing the newly established
    917917connection.  The tcp stream inherits any properties of the listener socket
    918 that are relevant (e.g. :keepalive, :nodelay, etc.) The original listener
     918that are relevant (e.g. :keepalive, :nodelay, etc.) Additional arguments
     919may be specified using STREAM-ARGS. The original listener
    919920socket continues to be open listening for more connections, so you can call
    920921accept-connection on it again."))
    921922
    922 (defmethod accept-connection ((socket listener-socket) &key (wait t))
    923   (accept-socket-connection socket wait #'make-tcp-stream))
    924 
    925 (defmethod accept-connection ((socket file-listener-socket) &key (wait t))
    926   (accept-socket-connection socket wait #'make-file-socket-stream))
     923(defmethod accept-connection ((socket listener-socket) &key (wait t) stream-args)
     924  (accept-socket-connection socket wait #'make-tcp-stream stream-args))
     925
     926(defmethod accept-connection ((socket file-listener-socket) &key (wait t) stream-args)
     927  (accept-socket-connection socket wait #'make-file-socket-stream stream-args))
    927928
    928929(defun verify-socket-buffer (buf offset size)
Note: See TracChangeset for help on using the changeset viewer.