PRIMER 22.1

Opening an X11 Connection to a Display: the DISPLAY Environment Variable

Opening an X11 Connection to a Display: the DISPLAY Environment Variable

The syntax of the DISPLAY variable
The simple case: displaying on this machine <= Probably all you need to know
Examples of networked graphics setup
Configuring under Unix/Linux
Configuring under Microsoft Windows.
Troubleshooting X11 graphics

The syntax of the DISPLAY environment variable

The X11 protocol requires that an "address" and "screen" number are nominated for its graphical output. This done with the DISPLAY environment variable, which has the form

(< address >):< server >(.< screen >) Entries in (..) can be omitted.
  • The <address> is a computer name or, more precisely, a network address. If omitted it means the local machine.
  • The <server> is the X11 "server" process. This is typically server #0, but it is possible to have more than one server running.
  • The <screen> is the screen number, starting at 0, on that computer (some machines have > 1 screen). It can be omitted if the display has only one screen.

The simple case: displaying on the screen attached to this computer

In the vast majority of cases all you will want to do is to display graphics on the screen attached to this computer. Therefore you need default "address", "server" #0, default "screen", which is achieved by setting:

DISPLAY = " :0 "

Sone examples of achieving this under different operating systems:

Unix/Linux C shell (/bin/csh, /bin/tcsh) setenv DISPLAY :0
Bourne/Korn shell (/bin/sh, /bin/ksh) DISPLAY=:0; export DISPLAY

Windows

In the System Properties panel

Variable = DISPLAY
Value = :0

If you are not interested in networked graphics then this is all you need to know about establishing a connection, and you can ignore the rest of this section.

The following examples show how DISPLAY could be set to display graphics in a range of local and networked locations:

DISPLAY Where the graphics will appear Comments
tigger:0 Server #0 (screen 0) on machine "tigger" The IP ( I nternet P rotocol network) address of "tigger" must be known to your system
170.177.15.2:0 Server #0 (screen 0) on the machine with the IP address 170.177.15.2 Since the IP address is given explicitly the remote machine name need not be known.
:0.1 Screen #1 on server #0 on this machine For a system with 2 screens, this will display on the second.
rainbow:0.1 Screen #1 on server #0 on machine "rainbow" The IP address of machine "rainbow" must be known, and it is assumed to have at least two screens.

The way the DISPLAY variable is set, and remote machine names are mapped to IP addresses, depends upon the operating system in use.

Defining DISPLAY on Unix and Linux systems

The DISPLAY enviroment variable ( $DISPLAY ) is set by:

C shell (/bin/csh /bin/tcsh)
setenv DISPLAY rainbow:0
setenv DISPLAY 170.177.15.2:1
Server #0 (screen 0 on machine "rainbow"
Server #1 (screen 0) on machine 170.177.15.2
Bourne/Korn Shell (/bin/sh /bin/ksh)
DISPLAY=rainbow:0; export DISPLAY
DISPLAY=170.177.15.2:1; export DISPLAY
Ditto

To save the DISPLAY variable a given user could place it in their startup files: "~/.cshrc" (for C shell) or "~/.login".

Machine name (hostname) to IP address resolution is defined in the file /etc/hosts . (This is owned by root, and requires superuser privileges if it is to be updated.)

This has any number of rows of the form:

<ip address> <name> (<name>) (<name>) ... IP addresses must have at least one "name", but may have any number of alternative aliases

For example:

170.177.15.2 atuhp002 atghp002 fred (This machine is known by any of three names)
193.20.116.16 abcsgi16
193.20.116.20 abcsgi20
Defining DISPLAY on Windows systems

The DISPLAY enviroment variable ( $DISPLAY ) is set in the System Properties panel.

The example below is from a Windows NT 4 system, but other variants of Windows will be similar.

This is accessed by:

=> =>

In the System Properties panel select the Environment tab, as shown here.

Click on the User Variables for <userid> (here Administrator ) and insert:

Variable: DISPLAY
Value: 170.177.1.92:0 Insert your own IP address or name

The click on Set to add it to your environment variable list.

Machine name (hostname) to IP address resolution is provided by a "Hosts" file (on Windows NT in C:\WINNT\SYSTEM32\drivers\etc) that has the same format as the Unix version above, ie:

<ip address> <name> (<name>) (<name>) ...

This may be updated using a text editor (eg WordPad).

Or on the Hummingbird Exceed TM emulator , which Oasys Ltd recommends, it may be maintained via a Host Editor:

=> => =>

The + and - buttons are used to add/remove entries in this panel

Troubleshooting X11 graphics

Problem Possible resolution
When you try to start an application you get the message:

Could not open display
This means that the DISPLAY variable has not been defined. See above for how to define it on Unix/Linux systems and Windows systems .
When you try to start an application you get the message:

Could not open display <name>:<server>.<screen>
This means that your machine (the client) cannot "see" the server machine, or the X11 server on that machine.
  1. Is machine <name> correct? Check its spelling, and remember that it is case-sensitive.
  2. Is <name> in your /etc/hosts file (unix) or Hosts file (windows) ?
  3. Is the IP address in there for <name> correct?
  4. Is the network path to <name> working correctly? (Try "ping"ing it.)
  5. Is machine <name> turned on and plugged into the network?
  6. Is the X11 window manager running on machine <name> ?
  7. Does <server>.<screen> exist on machine <name> ?
When you try to start an application you get the message:
Xlib: connection to <name>:<server>.<screen> refused by server
Xlib: Client is not authorised to connect to Server
This means that your client process has made contact with the server's X11 window manager, but has been refused permission to open a window on it. This is a security feature of the X11 system: server window managers must grant permission for clients to open windows, which may be done as follows:

On a transient basis, not "remembed" once you log out Type " xhost + " in any window on the server. This will grant permission for any remote client to open windows on this display.

To be more selective about which remote clients you will allow to open windows on a display type " xhost + name " where < name > is a remote computer name.

On a permanent basis, "remembered" across logout/login.

In the file /etc/X0.hosts add a list of computer names (each on a new line) that are permitted to open windows on this display. (This is for server #0, for server #1 put it into file /etc/X1.hosts, etc.)

To allow access to any host put a "+" into this file.


For more information (on a Unix/Linux host) type " man xhost " which describes X11 access control.
The application appears to start, but then fails with a message along the lines of:
X connection to <name>:<server>.<screen> broken (explicit kill or server shutdown)
This usually means that you have forgotten to reset your DISPLAY variable, and have popped up a window on someone else's screen. They, understandably, have got annoyed and killed the window (an "explicit kill"). Check that you are displaying graphics where you intended!

If this isn't the problem it may indicate that the server to which you are trying to connect is in distress and can't cope with the extra workload - see below.
The X11 server gets very slow, or locks up completely.

Normally there are no error messages, but a heavily overloaded server may produce "synchronisation" errors or other symptoms of its impending demise.
This can happen occasionally when the window manager on a server fails to cope with the load placed on it, typically during animation, and dies (a "server shutdown").

Server shutdowns may also occur if they run out of memory: usually caused by performing large "pixmap" or "object mode" animations in D3PLOT which cause the server to grab lots of memory. (Under Unix/Linux memory cannot easily be returned to the system's free pool once it has been allocated so, like middle-aged spread, memory consumption of a process will tend to grow but never diminish. This is not such a problem under Windows.)

An X server in distress may be shut down and restarted by the following methods:
  • Log out from the console, then select "command line", or "no windows", or some similar option (this will depend on the vendor and operating system) for a new login. Log in, then straight out again, and resume the normal "windows" login. This will shutdown then restart the X11 server, which usually sorts out problems.
  • If the display has locked up (no response to mouse or keyboard) then log in from a remote machine as "root", and kill the window manager process explicitly. (" ps -ealf | grep X " will usually find the process, and " kill -9 <process id> " will zap it.).
  • If you can't log in remotely, or don't have root access, reboot or turn the machine off and on again! Cruel but effective.
  • OpenGL Extension missing on remote server.

    Xlib: extension "GLX" missing on "< name >:< server >.< screen >
    You may see this if you try to open a remote OpenGL window on a local server that does not have the OpenGL/X extension "GLX" installed. You will not be able to open remote OpenGL clients until it has been installed.

    Note that you may still see this message on a machine that is able to display OpenGL graphics locally. This means that it can handle a "direct" OpenGL connection from a local client (which largely bypasses the X server), but that it does not have the ability to render "indirect" OpenGL requests. See " How does OpenGL work with X11? " for more information.

    But in the meantime you will have to use a X.. option to display remote graphics.
    Other errors, typically:
    X Error of failed request:
    Major opcode ...
    Minor opcode ...
    Resource id ...
    These usually suggest an error in Oasys LS-DYNA Environment. Please make a copy of the error message and contact Oasys Ltd Support for help and advice.