MAT 201B / CS 290I--Media Networks and Services
Homework Assignment #1
Due BEFORE Class on Thursday, October 11, 2001
Assignment Overview
The purpose of this assignment is to experiment with simple socket programming,
both in C and in Java. The basic funcationlity you will implement is
a client and server who communicate over a network.
The server functionality is reverse the capitalization of a given
text string of up to 80 characters length. The server is expected to run on
one machine (a well-known address (IP address + port number)) waiting for requests. Your
client code will contact the server and pass it a string.
The server will then change this string and send it back to the client.
The client will display the received string and exit.
Example
Assume that you started a server on machine 128.111.49.44,
listening to port number 32000. The syntax should look like the following:
-----------------------------------------------------------------------------
csil-machine1> server 32000 <enter>
-----------------------------------------------------------------------------
Then you ran a client at a machine using the following arguments:
-----------------------------------------------------------------------------
csil-machine2> client 128.111.49.44 32000 <enter>
Enter text: This is my text to be changed by the SERVER. <enter>
tHIS IS MY TEXT TO BE CHANGED BY THE server.
csil-machine2>
-----------------------------------------------------------------------------
At this point (after receiving one line to be reversed), the server
should exit.
Your task is to write such a server and client programs in C and in
Java using UDP and TCP. You will end up writing (and turning in) 8
different programs:
1- Server in C using UDP (file name to turn
in : server-c-udp.c)
2- Client in C using UDP
( file name to turn in : client-c-udp.c)
3- Server in C using TCP
( file name to turn in : server-c-tcp.c)
4- Client in C using TCP
(file name to turn in : client-c-tcp.c)
5- Server in Java using UDP (file name to turn
in : server_java_udp.java)
6- Client in Java using UDP
(file name to turn in : client_java_udp.java)
7- Server in Java using TCP
(file name to turn in : server_java_tcp.java)
8- Client in Java using TCP
(file name to turn in : client_java_tcp.java)
You will be turning in 8 (and only 8 - no header files... NOTHING else) files
as named above. Your server should not
output anything on the terminal and your client should have the exact
same interface as given in the above example. (Code will be run against
an automated checker... any deviation (e.g. printing additional messages)
will be counted as an incorrect program.
In order to compile your C code, use the following commands as a guide:
gcc -g -o client client.c -lsocket -lnsl
gcc -g -o server server.c -lsocket
To compile your Java code, use the following commands as a guide:
javac server_java_udp/tcp.java
javac client_java_udp/tcp.java
Assignment Turnin
You should turn in the source code for the 8 programs you wrote.
(There is no hard copy turnin for this assignment.)
Be sure to include your name in each program that you turnin.
To turn in
assignments, use the following command from the Computer Science CSIL lab:
csil-machine> turnin hw1@cs290i hw1
NOTE: The final "hw1" is a local directory containing the 8 and only 8 programs
you are turning in. Be certain to name this directory exactly "hw1".
ANOTHER NOTE: It is highly recommended that you use the CSIL machines
to do this assignment. All of the tools you will need are available there;
it significantly improves our ability to help you if you have problems; and it
ensures that if your programs work there, they will work when we grade them.
Assignment Grading
-
30 pts: UDP client/server in the first language
-
30 pts: TCP client/server in the first language
-
20 pts: UDP client/server in the second language
-
20 pts: TCP client/server in the second language
In addition to correctness, part of the points count towards how well
code is written and documented. NOTE: good code/documentation does not
imply that more is better. The goal is to be efficient, elegant
and succinct!