clients not using X abstract socket (Linux)?

James Cloos cloos at jhcloos.com
Thu Sep 11 12:57:11 PDT 2008


>>>>> "Eirik" == Eirik Byrkjeflot Anonsen <eirik at opera.com> writes:

>> The size passed to connect() should be the same as that passed to
>> bind() by the server, which would be 'strlen(file) + 1 +
>> offsetof(struct sockaddr_un, sun_path)', and not sizeof(addr), for
>> some reason.  See TRANS(SocketUNIXCreateListener) in Xtranssock.c.

Eirik> Could that be related to this quote from "man unix": "Note that
Eirik> names in the abstract namespace are not zero-terminated."

Yes, taht is exactly the issue.  The abstract sockets use Pascal-style
strings (lenght+data) rather than C-style (NULL-terminated), but with
the complication that the lenght is the used lenght of the whole struct
rather than just of the string.  Hense the need for offsetof¹.

-JimC

1]  If you know the strlen(3) of the name you could create a struct of
    just the right size, but that would require open-coding the struct
    rather than using the definition in the system include file.

-- 
James Cloos <cloos at jhcloos.com>         OpenPGP: 1024D/ED7DAEA6



More information about the xorg mailing list