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.
Edit
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.
:40
orHOSTNAME:40
, not40
. 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 '19 at 02:36$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 http://man7.org/linux/man-pages/man7/unix.7.html 's description of SOCK_STREAM. – 炸鱼薯条德里克 Mar 13 '19 at 03:11