Xnest is a display server implementing the X11 display server protocol that shows its output in a window. In other words, Xnest opens a window that works like another screen in which the user can open windows, etc.
At the protocol level, Xnest works like a client of the server hosting the window, and as a server with respect to the applications that opens windows within the Xnest session.
Xnest can be used to run a virtual desktop of another computer within a window. Xnest is also used for server debugging and for testing that applications work correctly at different screen sizes. Indeed, the user can choose the size of the Xnest window, which is also the size of the virtual screen it contains. This way, one can for example start an Xnest window with the size of the screen of a PDA to test whether an application works correctly on the screen of that device.
Xnest can be used to locally display the desktop of another computer.
Using XDMCP, Xnest can run a virtual desktop of another computer within a window, using for example the command: Xnest :10 -query other_computer_name. The remote machine must be configured to accept XDMCP incoming connections from the local machine.
Alternatively, Xnest can be run on the remote machine while showing its window locally. Like any other X application, this can be done by telling the remote application that the display is a local X server (e.g., setting the DISPLAY environment variable) and making the local X server accept connections from remote applications (e.g., using xauth); both actions can take place securely using ssh, for example using ssh -X other_computer_name to connect from the local to the remote machine. When the server is launched remotely (e.g., startx -- Xnest -geometry 800x600), since the display is forwarded back to the local machine, it will show the program window just like any other remotely launched application.
Furthermore, since Xnest behaves like a regular X server, a user can launch remote applications so that they connect to a local Xnest.