[iolib-devel] Abstract sockets

Stelian Ionescu stelian.ionescu-zeus at poste.it
Tue Feb 3 14:40:16 UTC 2009


On Tue, 2009-02-03 at 01:47 +0100, Julian Stecklina wrote:
> Hello,
> 
> the attached patch fixes abstract sockets for Linux. It least it tries
> as it does not work:
> 
> strace output from dbus-monitor:
> socket(PF_FILE, SOCK_STREAM, 0)         = 3
> connect(3, {sa_family=AF_FILE, path=@"/tmp/dbus-RhgMDI9FXg"...}, 23) = 0
> 
> strace output from my app using iolib:
> socket(PF_FILE, SOCK_STREAM, 0)         = 5
> connect(5, {sa_family=AF_FILE, path=@"/tmp/dbus-RhgMDI9FXg"...}, 110) = -1 ECONNREFUSED (Connection refused)
> 
> It seems as if connect (and bind) have to be passed "exact" sizes as
> addrlen parameter. But what is a good (i.e. portable) way to compute
> these? Using (+ 3 (length address)) (counting the address family word,
> the zero byte, and the string) would be quite a hack...

the correct way is to sum the offset of sun_path into struct
sockaddr_un(which is not always 2 because BSDs have an additional slot
named sun_len) to the length of the path(counting the initial 
#\Null but not the terminating #\Null), which is what the new function
actual-size-of-sockaddr-un does.

Test:

SOCKETS> (make-socket :address-family :local :remote-filename
(ensure-address "/tmp/dbus-ZIBJH6keOx" :family :local :abstract t))
#<active local stream socket connected to
"/tmp/dbus-ZIBJH6keOx" {D458259}>

-- 
Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/iolib-devel/attachments/20090203/935a91cd/attachment.sig>


More information about the iolib-devel mailing list