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.
Opening a remote desktop 
Xnest can be used to locally display the desktop of another computer.
- Using XDMCP, Xnest can be used to run a virtual desktop of another computer within a window. This can be done for example by running
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 accepting connections from remote applications (e.g., using xauth); both things are done using ssh, for example using
ssh -X other_computer_nameto 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, remote applications can be launched so that they connect to a local Xnest.
See also 
|Wikimedia Commons has media related to: XNest|