[usocket-devel] Support for UNIX sockets

Erik Huelsmann ehuels at gmail.com
Wed Aug 20 10:10:55 UTC 2008


On Fri, Aug 15, 2008 at 2:00 PM,
<kmkaplan+usocket-devel at ded.kim-minh.com> wrote:
> 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?

No, not as long as we can manage with the existing function.

Thanks for the extention. I only have intermittent net access atm.
I'll look at your contribution when I'm back home.

Bye,


Erik.

>
> 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