Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I am struggling a little on how to best approach this problem. I have wrote a server program that runs via xinetd, that obviously spits out data at the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    25

    Question how to use sockets to display a GUI at the server end


    Hi,

    I am struggling a little on how to best approach this problem. I have wrote a server program that runs via xinetd, that obviously spits out data at the client end. Fairly straightforward stuff?

    There is a point in my server code where I need to display an image/gui i.e something that runs on X11 that prompts a user to perform a task on the display connected at the the server side.

    So far I have written a test program that displays some text at the client end and then launches the browser at the server end. I have also set the following export.
    Code:
    export DISPLAY=:0
    and then goes on to launch my web browser. Works great when ran locally on the server and when I remotely telnet in to the server and run the code.

    However when I try to run the same piece of code as a xinetd service the export seems to have zero affect and the client terminal window displays errors associated with there not being a X11 server running.

    The code launches fine when I create a socket to serverip:6556 it just the ability to display gui programs to another display that does not seem to be working.

    Any ideas on how to best get round this.

    Cheers

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,677
    A common misperception about X is that the server is the remote system, but in actuality, the X server is running on the client system - it is what renders X code. The applications can run on the "server", and the display will be on the client's X-server. So, please show in detail how/where each part is playing. Where do you want the X-Windows output?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jul 2010
    Posts
    25
    Quote Originally Posted by Rubberman View Post
    A common misperception about X is that the server is the remote system, but in actuality, the X server is running on the client system - it is what renders X code. The applications can run on the "server", and the display will be on the client's X-server. So, please show in detail how/where each part is playing. Where do you want the X-Windows output?
    Ok, I have two PCs running Fedora. PC A is the client, PC B is the server (there may be more servers that A will connect to). I have a program that will run a GUI on PC A which is displaying the status of a program running on PC B. The connection is made with telnet/ssh with the program on PC B being configured as a service attached to a particular port.

    Now, from time to time, the program running on PC B will need to display some graphics on the server as well as serving the data on the socket connection with PC A.

    Hope this makes sense? Two PCs, one as a socket client the other as a socket server. With both PCs displaying a GUI that is reacting to the program running across the socket connection.

    Thanks for the reply.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,677
    What you have described is not an uncommon scenario. The exact approach will vary depending upon system requirements. Since the server applications being triggered by something like xinetd are running detached from a shell, the problem is the DISPLAY environment. This can be overcome if the application has some way to get the client's X server id (such as yourclient.xyz.com:0.0, or 192.168.1.100:0.0), in which case it can open windows on that system, or can use sockets to send data to a running program on the client. However, there are other approaches that might be more appropriate, depending upon performance and reliability requirements. In any case, for your situation, getting the correct remote client X-server display information to the applications running on the server that need to push screen output back to the client system. If the client is constant, then that could be in a configuration file on the server so when the service is started, it can get the display environment from that. If different client systems need to be able to get info from the server applications, then you might need some stub application that can get this information from the client when it starts up, and posts that to a temporary configuration file on the server.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #5
    Just Joined!
    Join Date
    Jul 2010
    Posts
    25
    Thanks Rubberman,

    I have had some success, Via terminal I can manually telnet into my server and run the program, with the display export being set through a shell script in the /etc/profile.d/. The GUI launches on the server and stdout are visible on in the client terminal.

    As you pointed out and as I have come to find, when trying to do the same process via xinetd the shell script does not run in the same way as if a telnet session had been opened up. This would be the crux of the problem for me at the moment.

    I am not sure if we are on the same wavelength here
    This can be overcome if the application has some way to get the client's X server id
    The server would be the only PC which would display any GUI the client would be 100% terminal based.

    I appreciate you help on this, I feel as though I am very close to solving this problem.

    Cheers

  7. #6
    Just Joined!
    Join Date
    Jul 2010
    Posts
    25
    A little update, i can display GUI by passing the export variable for display into the xinetd config file. However threads seem unpredictable, printfs are hanging the system and it just doesn't want to run nice.

    I think I need to take a different approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •