X52.9266 term0


This browser does not understand the APPLET tags or does not have Java enabled.
The above applet is a TCP server. Click on it if you don’t see it yet. To see what port it’s bound to and what its maximum x coördinate is, select View Source in your web browser and look at the HTML PARAM tags. To see the source code of the applet itself, click here.

The C++ program in the directory http://i5.nyu.edu/~mm64/book/src/term0/ (zero, not uppercase O) is a client for this server. It consists of the three source files

  1. term0.h
  2. main.C (written in the language C++)
  3. term0.c (written in the language C)
You have to read the first two files, but don’t bother looking at the third. These files are analogous to the three source files of the test program on pp. 86–90 of Chapter 1 of the book. To compile the client on i5.nyu.edu,
gcc -c term0.c
g++ main.C term0.o -lcurses -lsocket -lnsl
(with a minus lowercase L before the name of each library).

Launch the server first, simply by visiting this web page. (If you’re reading this, you&#rsquo;ve already launched the server.) Then launch the client by running

./a.out
To bring the server to life or to the top layer of your desktop, you may to click on it. Then type characters, ending with 'q'.

To run the server again, click on the “reload” button while keeping the “Ctrlrdquo; key depressed. (Without the “Ctrl” key, you will reload the page of HTML but not the applet(s) in it.) If the server is using the same port number as last time, you may have to wait two minutes before the port number becomes available again. Better View Java Console in case any messages appear.