The X protocol is used for sharing of graphical display resources across a network. Most UNIX systems use X for their graphical user interface. The X protocol allows a process to run on one machine and open a window for graphical output on another machine. In the X protocol, an X server usually corresponds to a display, and an X client is a program that shows data on that display. The X server is typically called X, and a sample X client is xterm, which opens a terminal window. X clients usually use port numbers starting at 6000 to make connections with X servers.
Most client programs communicate with the server via the Xlib client library. Beside Xlib, the XCB library operates more closely to X protocol. In particular, most clients use libraries such as Xaw, Motif, GTK+, or Qt which in turn use Xlib for interacting with the server.
X uses a client-server model. Furthermore, the X server program runs on a computer with a graphical display and communicates with various client programs. The X server acts as a middle man for the user and the client programs, accepting requests on TCP port 6000 for graphical output (windows) from the client programs and
- displaying them to the user(display), and
- receiving user input (keyboard, mouse) and
- transmitting it to the client programs.
In X, the server runs on the computer of a user, while the clients may run on remote machines.
This terminology reverses the common notion of client-server systems, where the client normally runs on the local computer of the user and the server runs on the remote computer.
This reversal often confuses new X users since the X Window terminology takes the perspective that the X Window program is at the centre of all activity.
For example, the X Window program accepts and responds to requests from applications, and from the user's mouse and keyboard input.
Therefore, applications (on remote computers) are viewed as clients of the X Window server program.
The communication protocol between server and client runs network-transparently: the client and server may run on the same machine or on different ones, possibly with different architectures and operating systems.
A client and server can communicate securely over the Internet by tunneling the connection over an encrypted connection.