[usocket-devel] Support for UNIX sockets

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

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@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@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/usocket-devel

On Fri, Aug 15, 2008 at 2:00 PM, <kmkaplan+usocket-devel@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@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/usocket-devel
participants (3)
-
Chun Tian (binghe)
-
Erik Huelsmann
-
kmkaplan+usocket-devel@ded.kim-minh.com