From dccd474d40850aa5dccae826e365f09b5ae1b9a2 Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Fri, 21 Mar 2008 00:44:19 +0100 Subject: [PATCH] Improve CREATE-SOCKET. Signed-off-by: Stelian Ionescu --- net.sockets/make-socket.lisp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/net.sockets/make-socket.lisp b/net.sockets/make-socket.lisp index a5a696f..f4afc4b 100644 --- a/net.sockets/make-socket.lisp +++ b/net.sockets/make-socket.lisp @@ -24,15 +24,20 @@ (in-package :net.sockets) (defun create-socket (family type connect external-format &key fd ibs obs) - (if (or ibs obs) - (make-instance (select-socket-class family type connect :default) - :family family :file-descriptor fd - :external-format external-format - :input-buffer-size ibs - :output-buffer-size obs) - (make-instance (select-socket-class family type connect :default) - :family family :file-descriptor fd - :external-format external-format))) + (cond + ;; this is necessary because passive sockets don't inherit from + ;; stream classes, therefore keyword args :INPUT-BUFFER-SIZE and + ;; :OUTPUT-BUFFER-SIZE are invalid for them + ((or ibs obs) + (assert (eq connect :active)) + (make-instance (select-socket-class family type connect :default) + :family family :file-descriptor fd + :external-format external-format + :input-buffer-size ibs + :output-buffer-size obs)) + (t (make-instance (select-socket-class family type connect :default) + :family family :file-descriptor fd + :external-format external-format)))) (defmacro with-close-on-error ((var value) &body body) "Bind `VAR' to `VALUE', execute `BODY' as implicit PROGN and return `VAR'. -- 2.11.4.GIT