clients not using X abstract socket (Linux)?

Julien Cristau jcristau at debian.org
Wed Sep 10 09:37:38 PDT 2008


On Wed, Sep 10, 2008 at 11:28:59 -0500, Xavier Toth wrote:

> I noticed that the socket file /tmp/.X11-unix/X0 is being created on
> my Fedora 9 box despite the fact that the X server is creating an
> abstract socket which I would have thought was the preferred method of
> connecting to the server. I wrote a little test to connect to the
> abstract socket but it fails with 'Connection refused'. netstat makes
> it look like no clients are connected to the abstract socket. Any idea
> what's happening here and why my test can't connect?
> 
<snip>

> static int _open_unix(const char *file)
> {
>     int fd;
>     struct sockaddr_un addr = { AF_UNIX };
> 
>     memset(&addr, 0, sizeof(addr));
>     addr.sun_family = AF_UNIX;
> 
>     fd = socket(AF_UNIX, SOCK_STREAM, 0);
>     if(fd == -1)
>         return -1;
> 
>     /* try the abstract socket first */
>     strcpy(addr.sun_path + 1, file);
>     if(connect(fd, (struct sockaddr *) &addr, sizeof(addr)) != -1) {
>         return fd;
>     }
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.

Cheers,
Julien



More information about the xorg mailing list