Homework 4, CSC350 Spring 2001
Due Monday, Feb 26, noon
- type getcopy TCPClient.java, and then getcopy TCPServer.java,
after logging into hermite with your class account.
Compile these Java applications by typing
javac TCPClient.java
and
javac TCPServer.java
As in class, you need two different sessions, whether it is a PowerTerm
session or a telnet session. In one session run the server by typing
java TCPServer
and then in the second session run the client by typing
java TCPClient
After you get this to work, copy TCPServer.java into TCPServer2.java
and change the class name to TCPServer2! Modify the server so
it returns a substring of the original string, between positions
3 and 10. The string class is part of the Java.lang package. You can
read about it and the methods it has available on the
Sun API. Go to http://java.sun.com/products/jdk/1.2/docs/api/index.html
and in the big frame, click on Java.lang. Then find the string class in
the listing and click on that link. Scroll down past the constructor
methods to the class methods and find one that works for this purpose.
Use that method instead of the method toUpperCase()
used in TCPServer.java. Compile TCPServer2.java and run it.
- type
getcopy WebServer.java
to get a copy of the webserver application described in your textbook.
copy this file into one called WebServer2.java and
change the class name to WebServer2! Add html as another option
(in addition to gif and jpeg) and test it on an
html page with one image, namely duke5.gif
type
getcopy duke5.gif to get a copy of duke5.gif
- Next, try the web server with two images. Type
getcopy duke6.gif to get a similar duke image
Does it work?
- Read in Java Networks book:
- The chapter on Threads (ch5 - only in 2nd ed)
- The chapter on Internet Addresses (ch6 in 2nd ed, ch4 in 1st ed).
- The chapters on Socket and ServerSocket (ch 10-11 on 2nd ed, 7-8 in 1st ed).
Please submit as an electronic file, using your class account.
You can log into hermite via telnet. The host name is
hermite.csc.smith.edu
To submit homework 4, put it the modified server in a file called TCPServer2.java
and type:
submit homework4 TCPServer2.java
Also put the modified web server in a file called WebServer2.java and type:
submit homework4 WebServer2.java