In order to use this project, you will need to have access to X-Windows (the standard interface on the Suns). On the campus PCs, in the past this meant you would likely need to install Micro X-Win32. Once installed, start X-Win32 and X-Util32. If you are unfamiliar with using this form of X-Windows, you might want to do the following: In X-Util32, define a new session (connection to a particular server) by going to Sessions->NewSession, and give your session a name such as MarsX, select XDMCP, and give the hostname mars.eecs.lehigh.edu. That defines a session. You then need to start the session, by clicking on the X-Win32 program in the task bar and choosing Sessions->MarsX. You will then need to log in to the machine you defined. Now your PC will display X graphics if any are sent to it.However, you need to do a little more to get programs to send their output to your PC. First, find out what your PC's IP address is. In X-Util32, choose Options->Display... to see your IP address. Then, at your bash shell, type export DISPLAY=a.b.c.d:0.0 (where you replace a.b.c.d with your PC's IP address). Now X programs that you run from this shell will display automatically on your PC screen.
Alternatives to X-Windows include running VNC server on a sun and a VNC client on your PC, or installing cygwin (a unix-like environment) and X-windows on your PC. Sometimes I use a live Cygwin/X-Windows CD that lets me run X-Windows on Windows XP machines without installing on the machine.
Once you have X-Windows operational and a shell open on one of the Suns, you can continue. This is the default if you are logged in at the console of one of the Suns.
OBLIGATORY ENTERTAINMENT VALUE: Experiment with the example robowar system. To connect, use:
% ~brian/cse342/bin/robowar-client-x86-solaris -server europa -auto -scale .5 -name MyNameIf you are on the old sparc-based suns, use:
% ~brian/cse342/bin/robowar-client-sparc-solaris -server europa -auto -scale .5 -name MyNamewhere the
-server
option identifies the host on
which the server is running, -auto
indicates that your
client should auto-restart another ship when your ship is destroyed
and -name
lets you use a screen name for your ship
(instead of MyName). The
-scale option lets you adjust the relative size of the screen it uses for
display (.5 makes the screen small enough to use other windows on your
display).
BTW, if over the rest of this semester you ever find that the server is not running (probably on europa), please send me mail and I will restart it.Once
robowar-client
is running, you can enter the following
commands at the keyboard:
x | Open the X display (enter once, as first command) |
r | (Re)start your ship (enter once, as second command) |
a | Turn left |
d | Turn right |
s | Fire thruster |
<spacebar> | Fire torpedo |
h | Hyperspace |
EXERCISE: Write a client program that incorporates the following functions:
0 (encoded in a single 8-bit byte)
| len (a single byte)
| Player name (len bytes)
|
A hint: the server expects to receive all of a message at once (e.g., in the same packet). To help ensure this, create your message in a temporary buffer and then send your message with a single system call (e.g., with write(2)).
0 (a single byte)
| Player ID (32-bit integer)
|
Typical valid IDs are small, non-negative values.