Remotely run the application on X11

Source: Internet
Author: User
Article title: run applications remotely on X11. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
  
By Guido Socher
  
Display Concept
Each X Window application reads the DISPLAY environment variable at startup to determine which computer the image will be sent. This works with the network performance of X to make it possible to remotely run graphical programs. When you remotely operate an application, you use the CPU resources of the remote computer. The complete Graphical User Interface (GUI: Graphical User Interface) will be displayed on your local computer.
Here, the network speed is also a factor to consider, but the common 10 Mbit/s connection Lan is enough.
   
Why are you doing this?
There are many "network graphics" applications. Some companies use such programs to remotely control devices that may be thousands of kilometers away and you can use the same software to control them as if you were there.
You may have two machines, one high-speed 1 GHz computer and the other 133MHz old Pentium. You can enjoy new machines without having to sit in front of them. Maybe your sister is sitting in front of the new computer and logging on to it. However, this does not affect your use of your new computer.
How to implement it?
All X Window applications, such:
  
Gimp, xterm, konquerer, and netscape are all network clients connected to one server, which is X-server. The X-server task is to tell the graphics hardware to draw images on your monitor and read the input of the mouse and keyboard. The client (that is, your application such as gimp and netscape) sends commands such as how to draw the framework and buttons to X-server. in turn, the client receives mouse and keyboard events from X-server. Obviously, you need some verification, or anyone else can mess up others' screens. There are two programs for control:
-Xhost: using this program, you can allow any user on a given machine to write your screen. For example, if you are sitting in front of a machine named philosophus, to allow any program on the host movietux to write your philosophus screen, you can enter the following command:
  
Xhost + movietux
You must enter
  
  
-Xauth: this is a reliable cookie-based verification method. Here you can set permissions for individual users. This method is much safer than xhost. it uses the cookie stored in the file. Xauthority in the user's home directory. if a remote machine has a valid cookie in this file, it agrees to access it. To copy the cookie of the machine (philosophus) in front of you to the machine (movietux) where you want to run the program, you can use one of the following methods:
Xauth extract-philosophus: 0.0 | ssh movietux/usr/X11R6/bin/xauth merge
Or
Scp ~ /. Xauthority movietux:
  
  
Before the program starts running, it goes through the following process:
The client checks the DISPLAY environment variables to find another server and connects it to the X-server of this host.
The server checks whether the client is allowed to send data to itself. if the client is verified, the server starts to display images on the screen.
Environment variable DISPLAY syntax:
Bash: export DISPLAY = hostname: displaynumber. screennumber
Tcsh: setenv DISPLAY hostname: displaynumber. screennumber
  
Displaynumber and screennumber are not discussed here. they are usually 0: 0. this is an example of bash:
Export DISPLAY = philosophus: 0.0
  
   
Start an application remotely
After the theory, let's look at a practical example. We will return to the philosophus machine and prepare to remotely run some programs on the movietux machine.
Tell your X-server to allow clients on movietux to display images on your screen again:
Xhost + movietux
Log on to the remote host movietux:
Slogin-l username movietux
Now you have logged on to movietux, and every command you run is executed on movietux.
Export DISPLAY = philosophus: 0.0
Run the program, for example:
Netscape &
If movietux is a powerful machine, you will notice that html display in netscape is faster than local display. At the same time, you will not notice from the usage that this netscape is not running locally, because you also use the mouse, keyboard to perform the same operations as the local.
It's cool, isn't it?
Taking the display with you
Although it is relatively simple to remotely run an application, you need to set the DISPLAY and then perform the operation. It can also be completed automatically:
If you use ssh to log on to the remote host, the DISPLAY will be automatically set correctly. It is recommended that other remote logon programs support DISPLAY. However, ssh is very popular.
If you use slogin or other commands, you can install the following script on the remote host.
For tcsh:
# Take your display with you at remote login:
# Put it into your ~ /. Login file
Set whoami = 'who-ml'
Set remhost = 'expr "$ whoami ":'.*((.*))''
If ("$ remhost "! = "") Then
Setenv DISPLAY "$ remhost": 0.0
Endif
  
Run "who-ml" to obtain the machine name of the remote host. This command returns a result similar to the following:
> Who-ml
Movietux! Guido pts/3 Oct 26 21:55 (philosophus.tux.org)
  
If you are using bash then you need to the following script: If you are using bash, you need the following script:
# Take your display with you at remote login:
# Put it into your ~ /. Bash_profile
Whoami = 'who-ml'
Remhost = 'expr "$ whoami ":'.*((.*))''
If [-n "$ remhost"]; then
DISPLAY = "$ remhost": 0.0
Export DISPLAY
Fi
  
   
OpenGL
When the network performance of X Windows System is good, the figure shows a little slow. you should transmit your data through the network protocol. Generally, you will not notice any difference.
  
Graphics acceleration and fast-moving application-form acceleration games are usually based on OpenGL (Open Graphics Library) and GLX (OpenGL Extension to the X Window System. These libraries provide a hardware-independent program interface that directly accesses the 3D accelerator on the video card. That is: The application uses points, lines, and polygon to describe the shape of an object, and transmits these to the video card. all rendering work is performed inside the graphic hardware. This provides a high graphics speed.
  
Currently, most Linux graphics card drivers (X servers) do not support remote GLX/OpenGL hardware acceleration, but local acceleration is supported. The result is that remote OpenGL programs are almost immobile and very slow. However, the NVidia graphics card driver with closed code is an exception. They have a direct rendering interface that supports remote application non-direct rendering.
Conclusion
X11 can easily exert the power of your network. You can work remotely as you do locally. The only difference is that the files and directories you see are on the remote host. However, by installing NFS and NIS, you can hide this small difference and use the CPU resources on the same powerful computer with your network with peace of mind.
Link
X11 system, x.org
Xfree86.org the X11 system used with Linux
  
  
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.