From Can I specify an arbitrary `$DISPLAY`?

Do not confuse the actual display (your monitor(s)), the X11 server ("display"), and the way it's accessed via sockets or other means: DISPLAY=:0 and DISPLAY=localhost:10 as forwarded via ssh refer to the same display/xserver, the same video card, and the same monitor.

$DISPLAY is provided to start a X server. Does $DISPLAY specify a listening socket and a rendering target of the X server at the same time? If yes, how does it manage to specify two different kinds of things?

  • $DISPLAY specifies a socket. For example if $DISPLAY is :40, it corresponds to a port 6040 or a unix domain socket named after 40.

    Is the socket which $DISPLAY specifies the listening socket of the X server?

  • Is $DISPLAY also supposed to specify a rendering target (i.e. a display device or its emulator on which the X server will render something)?

Is it correct that

X client <->  X server <-> rendering target

and a X client can't communicate with a rendering target directly but indirectly via a X server?


  • unix.stackexchange.com/questions/503870/… So most phrases used in your question is meaningless. An X server is a display. Use the right syntax :40 or HOSTNAME:40, not 40. X client and X server communicates with X11 protocol(over TCP or UDS), not nessacarily sockets because some platform doesn't have it. For linux, sockets or any file can't be owned by a process, linux doesn't have this concept. – 炸鱼薯条德里克 Mar 13 at 2:36
  • There's no such thing called "socket addressing a display of a X server", nobody knows what do you mean, there's only address of a X server. X client and X server communicates with X11 protocol(over TCP or platform-dependent-IPC). $DISPLAY is an env that most X client can regonise and then connect to the desired address(they expect an X server running on that address). The sockets created by X server(on most posix platform) include listening sockets and connection sockets, of course they're differnet, see man7.org/linux/man-pages/man7/unix.7.html 's description of SOCK_STREAM. – 炸鱼薯条德里克 Mar 13 at 3:11
  • @炸鱼薯条德里克 Does $DISPLAY specify a socket and a rendering target at the same time? I have tried to update my post to clarify my questions. – Tim Mar 14 at 23:45
  • It specifies an address and an X screen(assuming an X server listening on that address). It specifies neither a socket nor a render target. – 炸鱼薯条德里克 Mar 15 at 0:54
  • @炸鱼薯条德里克 "It specifies an address and an X screen". can the address be a socket? can the X screen be a rendering target (e.g. monitor)? – Tim Mar 15 at 1:02

A X server is said to be started in a display

No. An X server provides a communication endpoint for X clients. X clients choose the server they want to communicate with either through a command line option or through an environment variable. From the view of the client, this is the "display" it uses, therefore the option is often -display, the environment variable is $DISPLAY, and the relevant library functions have "display" in their name.

Communication can either be over the network (unsafe, and mostly disabled today), or locally. The unix construct for providing both kinds of endpoints is called "socket" (see man 2 socket). The "display" value codifies (1) the host, (2) a display number that gets mapped to well-known port numbers or unix domain paths (for local communication), (3) the screen number (today mostly 0 by default, because most X servers don't provide multiple screens), in the format hostname_or_address:display_number.screen_number.

Many clients can connect to the same "socket" provided by a single server, so

Are "socket" addressing a display of a X server (in the first sentence) and "socket" created by a X server and connected to a X client (in the second sentence) the same "socket"?

makes no sense.


Is it correct that

X client <->  X server <-> rendering target

and a X client can't communicate with a rendering target directly but indirectly via a X server?

Assuming that you mean by "rendering target" "some piece of hardware that can be displayed as graphics on a monitor", then yes, that's essentially correct.

However, the X server doesn't somehow communicate with the "rendering target", the X server takes exclusive control of the "rendering target" (usually, a piece of memory on the graphics card that serves as framebuffer, and a piece of hardware that displays the framebuffer on one or several monitors, all abstracted through various driver and kernel layers).

Also, that is the situation for the original X protocol. With the advent of OpenGL extensions, what happens is that the X client can use an extension of the X protocol to gain more direct access to the "rendering target" (the kernel driver for the GPU), bypassing the X server. And today most applications use OpenGL to accelerate the graphics... which is why you loose hardware acceleration as soon as an X client connects over the network to an X server on a different machine.

  • Please don't say Unix domain ports, just path or address of Unix domain sockets. It confuses people, uds doesn't have the concept "port" – 炸鱼薯条德里克 Mar 13 at 13:25
  • Thanks. I have tried to clarify my questions. – Tim Mar 14 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.