Thursday, November 29, 2007

Running a ported program remotely

Because text-handling capabilities of the TurboC libary are based on standard i/o streams (stdin/stdout) and on ncurses, the text-based programs work just fine when run remotely but hosted on another computer:
xterm +sb -tn linux
telnet/rlogin/ssh/etc. (to connect to host)
PortedProgram PortedProgramOptions ...
Actually, there is some difficulty correctly sizing the screen when ssh is used for the remote login, though telnet and rlogin seem to work properly in the cases I've tried. What happens with ssh is that if the xterm window is manually resized, it doesn't automatically resize itself until a key is pressed. I imagine that the desire to remotely run a ported Turbo C program is rare, so this is unlikely to pose a problem for many people.

To a certain extent, graphically-based programs can also be run remotely, because the TurboC library's graphical capabilites are based on the X-window system. However, exploiting this capability is hardly a user-friendly process. The following steps are necessary:

  1. You must set up the X-server at the user's location to accept input from the remote computer hosting the ported TurboC program. This is done with the command-line program xhost, and you need to know the ip address of the remote computer:
    • xhost RemoteIpAddress
  2. The DISPLAY environment variable must be properly initialized on the remote computer to indicate the user's computer. Typically this is done automatically when you log in (with telnet/rlogin/ssh ), but not necessarily. So after logging in, but before running the ported program, you might need to set up DISPLAY. In the bash shell, this would look something like this:
    1. export DISPLAY=UserIpAddress:0.0
Putting it all together, the complete sequence of steps for running the program remotely might become something like this:
xterm +sb -tn linux
xhost RemoteIpAddress
telnet RemoteIpAddress
export DISPLAY=UserIpAddress:0.0
PortedProgram PortedProgramOptions ...
Unfortunately, firewalls and/or network-address-translation may wreak havoc with this scheme, and you may find that the graphics capabilities of the ported Turbo C programs simply don't work remotely. Text-only ported programs are fortunately less affected (i.e., not affected) by these problems.

No comments: