1 (in-package :sb-bsd-sockets)
3 #|| <h2>Local (unix) domain sockets</h2>
5 Local domain (AF_LOCAL) sockets are also known as Unix-domain sockets, but were
6 renamed by POSIX presumably on the basis that they may be
7 available on other systems too.
9 A local socket address is a string, which is used to create a node
10 in the local filesystem. This means of course that they cannot be used across
15 (defclass local-socket (socket)
16 ((family :initform sockint::af-local)))
18 (defmethod make-sockaddr-for ((socket local-socket) &optional sockaddr &rest address &aux (filename (first address)))
19 (let ((sockaddr (or sockaddr (sockint::allocate-sockaddr-un))))
20 (setf (sockint::sockaddr-un-family sockaddr) sockint::af-local)
22 (loop for c across filename
23 ;; XXX magic constant ew ew ew. should grovel this from
25 for i from 0 to (min 107 (1- (length filename)))
26 do (setf (sockint::sockaddr-un-path sockaddr i) (char-code c))
28 (setf (sockint::sockaddr-un-path sockaddr (1+ i)) 0)))
31 (defmethod size-of-sockaddr ((socket local-socket))
32 sockint::size-of-sockaddr-un)
34 (defmethod bits-of-sockaddr ((socket local-socket) sockaddr)
35 "Returns filename of SOCKADDR"
36 (let ((name (sb-c-call::%naturalize-c-string
37 (sb-sys:sap+ (sockint::array-data-address sockaddr)
38 sockint::offset-of-sockaddr-un-path))))
39 (if (zerop (length name)) nil name)))