But back to Xlib for the moment.
The main task of Xlib is to translate C data structures and procedures in the special form of X protocol messages which are then sent off. Obviously the converse of receive and convert to C structures is performed as well. Xlib handles the interface between client (application) and the network as shown in the following Fig. 3.
Fig. 3 Clients, Servers and Xlib