CS345 Operating Systems
Spring 2004
Laboratory Assignment 2
The purpose of this
assignment is to illustrate socket programming and to give you the
opportunity to develop a simple client server application. You will be
using the Java environment provided on the Windows XP machines in the
CS Lab. Be sure to complete the pre-lab activity before beginning
the actual lab.
Pre-lab
- Read section 4.6.1 in our
textbook and make sure you understand every line of code in figures
4-18 Date Server and 4.19 Date Client
(retrieve the files for eventual
use)
- Review an online tutorial on
Java socket programming. A couple of good ones are:
Lab
- Make sure you can successfully
run the existing Date Server, a telnet client, and finally the Date
Client on the same machine
- Compile and run the Date
Server from JGrasp and or the cmd window.
- Open a cmd window and
type the command "telnet localhost 6013. What happens?
- Compile and run the Date
Client. What happens?
- Make sure you can run the Date
Server and Date Client on different machines
- Run the Date Server on one
machine
- Modify the Date Client to
access the Date Server running on a different machine
- Run the Date Client.
What happens?
- Write your own server and
client JAVA programs
- Write a server program that
will listen on port 6000 and do the following:
If the server receives a "DATE" string on port 6000
it will return the date.
If the server
receives a "TIME" string on port 6000 it will return the time.
If the server receives anything else
on port 6000 it will return the string "ERROR"
- Write a client program that
will connect to port 6000 on the server and send the DATE and TIME
"commands" and then print to the screen the response from the
server. Also, send something other than DATE and TIME and verify
that the server returns ERROR. Show Prof. Tis the output from your
program.