CSC 465
Assignment 1
Introductory lab exercises
Due: end of today’s lab period, January 25, 2001.
Some of the exercises require you to answer questions. Your answers should be recorded using a word processor, then pasted into the body of an email addressed to PeteSanderson@smsu.edu. Be sure to include your name. You may alternatively print it and hand it in.
Exercise 1: Log into the online textbook. Instructions are given on the cardboard insert in the front of your book. If you do not have one, pair up with someone who does. If you have not already activated your access, this will require that you:
a. Turn your browser to http://www.awl.com/kurose-ross
b. Click on “online book”
c. Select “register here”
d. Enter the activation ID and password from your insert.
e. If this is successful, you will be given an online registration form and among other things will specify a user ID and password for future use.
There will be no incentive in this course to need “private” access to the online book, so don’t be afraid to share your ID and password if requested. I suggest you use “csc465” as the password. I do not know if the system will allow multiple simultaneous sessions for the same user ID – we’ll cross that bridge if we come to it.
Exercise 4: Chapter 2 describes several common Internet applications and their network protocols. One of these protocols is HTTP, used for web communication. In this exercise, you will use a little HTTP to communicate directly with a web server from a command line using TELNET.
a. Although this can be done from Windows in a command-line (DOS) window, it appears to be much cleaner going from a unix command prompt. Nearly all of you have login IDs on csc.smsu.edu. If you don’t, pair up with someone who does – you can also do this from Windows but it seemed uglier when I did it. Login to csc.smsu.edu.
b.
Try the example from textbook top of page 94. Online book section 2.2.3. It is:
telnet
www.eurecom.fr 80
GET /~ross/index.html HTTP/1.0
(press Enter key twice)
c. What is the output of that command?
d. What happened to the connection?
e. Look up the same web page using your browser. Does it contain any pictures?
f. Was the picture downloaded when you did the GET?
g. Look at the HTML source code, note the filename of the picture, and download the picture only.
h. Now download the picture from the command prompt, using the GET command. What happens?
i. Download /~ross/banana.html from the command prompt, using the GET command. What happens?
j. Repeat steps b, h, and i using HEAD instead of GET. What happens?
EXERCISE 5: Enter and run the Java TCP client and server programs described in Chapter 2 section 6. From the online textbook, you can copy and paste the source code. The programs appear on pages 141 (client) and 145 (server) of the textbook.
TCPClient.java accepts a line of text input from the keyboard and transmits it to the server through a TCP socket. The server responds with the same text converted to upper case. The client displays this result then terminates.
TCPServer.java accepts lines of text from clients (one at a time), converts the text to upper case and returns this result to the client. The server process does not terminate on its own, but must be terminated by an outside action (such as Ctrl-C).
Run these programs (almost) as given. When you have done this successfully, demonstrate it to me and then you may leave.
IMPORTANT NOTE: The value 6789 in these programs is the communication “port.” Before running the programs, you must change it to a randomly selected value between 1024 and 9999 (both client and server must use same port). Only one server process on the entire system can be running on a given port at a time (e.g. a port is a global resource). Also change “hostname” to “localhost”, and run both client and server on the same machine.
Java is an object-oriented language, but you will see that TCPClient.java and TCPServer.java are not!
Java.
The programs have been tested both on Linux and Windows NT systems using Sun's JDK, which is available in several forms:
1. JDK is installed in all CSC classroom laboratories
2. JDK installation files are available in folder CSCTOOLS on the Eccentric server. See the "readme" file for details. You'll need a ZIP disk.
3. JDK is available for download from Sun's Java website, java.sun.com.
Quick primer on jdk
use for single file programs.
1. Source code is stored in text file having ".java" extension. Compose using your favorite text editor. You should include one class in the file and give the file the same name as the class.
2.
Source code is "compiled" into byte-code with the
command: javac filename.java
Creates byte-code file filename.class.
3.
Once step 2 is completed without error, run the program with
command: java classname
(good reason for file name to be same as class name).
Quick primer on
testing client-server applications.
1. For testing, you can both the server and the client on the same machine. In the provided program, the machine name is hardcoded into the client.
2. If running on an NT system, open up one DOS window for the client and a different DOS window for the server. Run the server program first, then the client. Note that the server does not terminate, and you can run the client over and over. Terminate the server with Ctrl-C.
3. If running on Linux, you can either open up a different window for client and server, or run the server in background. If you choose the latter, run the server first, and put an "&" as the last character on the command line to run it in the background. Then run the client. When finished, terminate the server either by killing its process ID, or by bringing it back to the foreground with the "fg" command then killing it with Ctrl-C.
[ assignments | CSC 465 | Peter Sanderson | Computer Science | SMSU ]
Last
reviewed: 25 January 2001
Peter Sanderson ( PeteSanderson@smsu.edu )