[usocket-devel] Support for UNIX sockets

Chun Tian (binghe) binghe.lisp at gmail.com
Sun Aug 17 09:21:31 UTC 2008


Good, new feature come in again.

Maybe that's USOCKET's next goal after UDP support. I think new  
usocket classes should be created to support them, or just make  
AF_INET as a option when create new socket to let user choose AF_LOCAL  
instead.

--binghe

在 2008-8-15,下午8:00, kmkaplan+usocket-devel at ded.kim-minh.com 写道:

> I need to connect to a UNIX domain socket using usocket.  Here is what
> I came up with to make it work in SBCL.  Should this be done in  
> another
> function?
>
> Index: backend/sbcl.lisp
> ===================================================================
> --- backend/sbcl.lisp   (révision 423)
> +++ backend/sbcl.lisp   (copie de travail)
> @@ -213,8 +213,12 @@
>              (not (fboundp 'sb-bsd-sockets::sockopt-tcp-nodelay)))
>     (unsupported 'nodelay 'socket-connect))
>
> -  (let* ((socket (make-instance 'sb-bsd-sockets:inet-socket
> -                                :type :stream :protocol :tcp))
> +  (let* ((socket (typecase host
> +                  (pathname
> +                   (make-instance 'sb-bsd-sockets:local- 
> socket :type :stream))
> +                  (t
> +                   (make-instance 'sb-bsd-sockets:inet-socket
> +                                  :type :stream :protocol :tcp))))
>          (stream (sb-bsd-sockets:socket-make-stream socket
>                                                     :input t
>                                                     :output t
> @@ -222,7 +226,9 @@
>                                                     :element-type  
> element-type))
>          ;;###FIXME: The above line probably needs an :external-format
>          (usocket (make-stream-socket :stream stream :socket socket))
> -         (ip (host-to-vector-quad host)))
> +         (raw-address (typecase host
> +                       (pathname (list (namestring host)))
> +                       (t (list (host-to-vector-quad host) port)))))
>     (when (and nodelay-specified
>                (fboundp 'sb-bsd-sockets::sockopt-tcp-nodelay))
>       (setf (sb-bsd-sockets:sockopt-tcp-nodelay socket) nodelay))
> @@ -232,7 +238,7 @@
>                                    (or local-host *wildcard-host*))
>                                   (or local-port *auto-port*)))
>     (with-mapped-conditions (usocket)
> -      (sb-bsd-sockets:socket-connect socket ip port))
> +      (apply 'sb-bsd-sockets:socket-connect socket raw-address))
>     usocket))
>
> (defun socket-listen (host port
>
> _______________________________________________
> usocket-devel mailing list
> usocket-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/usocket-devel




More information about the usocket-devel mailing list