CLOCC/PORT uses the following code to create socket streams: (defun open-socket (host port &optional bin) "Open a socket connection to HOST at PORT." (declare (type (or integer string) host) (fixnum port) #+(or cmu scl) (ignore bin)) (let ((host (etypecase host (string host) (integer (hostent-name (resolve-host-ipaddr host)))))) #+(or cmu scl) (make-instance 'stream:socket-simple-stream :direction :io :remote-host host :remote-port port) #+(and sbcl db-sockets) (let ((socket (make-instance 'sockets:inet-socket :type :stream :protocol :tcp))) (sockets:socket-connect socket (sockets::host-ent-address (sockets:get-host-by-name host)) port) (sockets:socket-make-stream socket :input t :output t :buffering (if bin :none :line) :element-type (if bin '(unsigned-byte 8) 'character))) #+(and sbcl net.sbcl.sockets) (net.sbcl.sockets:make-socket (if bin 'net.sbcl.sockets:binary-stream-socket 'net.sbcl.sockets:character-stream-socket) :port port :host host)))
this returns a STREAM:SOCKET-SIMPLE-STREAM object in CMUCL. (what does it return in SBCL?) OTOH, to accept outside connections, CLOCC/PORT uses (defun open-socket-server (&optional port) "Open a `generic' socket server." (declare (type (or null integer #-sbcl socket) port)) #+(or cmu scl) (ext:create-inet-listener (or port 0)) #+(and sbcl db-sockets) (let ((socket (make-instance 'sockets:inet-socket :type :stream :protocol :tcp))) (sockets:socket-bind socket (vector 0 0 0 0) (or port 0))) #+(and sbcl net.sbcl.sockets) (net.sbcl.sockets:make-socket 'net.sbcl.sockets:passive-socket :port port)) (defun socket-accept (serv &key bin wait) "Accept a connection on a socket server (passive socket). Keyword arguments are: BIN - create a binary stream; WAIT - wait for the connection this many seconds (the default is NIL - wait forever). Returns a socket stream or NIL." (declare (type socket-server serv) #+(or (and allegro (version>= 6)) openmcl) (ignore bin)) #+(or cmu scl) (when (sys:wait-until-fd-usable serv :input wait) (sys:make-fd-stream (ext:accept-tcp-connection serv) :buffering (if bin :full :line) :input t :output t :element-type (if bin '(unsigned-byte 8) 'character))) #+(and sbcl db-sockets) (let ((new-connection (sockets:socket-accept serv))) ;; who needs WAIT and BIN anyway :-S new-connection) #+(and sbcl net.sbcl.sockets) (net.sbcl.sockets:accept-connection serv (if bin 'net.sbcl.sockets:binary-stream-socket 'net.sbcl.sockets:character-stream-socket) :wait wait)) this returns an FD-STREAM object in CMUCL. (what does it return in SBCL?) is it possible to create the same type of object in both SOCKET-ACCEPT and OPEN-SOCKET? thanks! -- Sam Steingold (http://www.podval.org/~sds) running w2k <http://www.dhimmi.com/> <http://www.iris.org.il> <http://www.jihadwatch.org/> <http://www.memri.org/> All extremists should be taken out and shot.