MAT 201B / CS 290I--Media Networks and Services
Homework Assignment #1
Due by 11:59pm on Thursday, October 9, 2003

Assignment Overview

The purpose of this assignment is to experiment with simple socket programming, both in C and in Java. The basic functionality you will implement is a client and server who communicate over a network. The server functionality is to a) remove all vowels, and b) reverse the capitalization of the consonants in 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.


Assume that you started a server on machine, listening to port number 32000. The syntax should look like the following:


csil-machine1> server 32000 <enter>               (in this line, “server” will be replaced by one of the names given below)


Then you ran a client at a machine using the following arguments:


csil-machine2> client 32000 <enter>        (in this line, “client” will be replaced by one of the names given below)
Enter text: This is my text to be changed by the SERVER. <enter>

At this point (after receiving one line to be reversed), the server and client should both 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 :
6- Client in Java using UDP        (file name to turn in :
7- Server in Java using TCP        (file name to  turn in :
8- Client in Java using TCP        (file name to turn in :

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/
javac client_java_udp/

To run your Java code on the CSIL machines, use the following commands as a guide:

            java server_java_udp 32000

            java client_java_udp 32000


Assignment Turnin

Include your name as a comment in each of the files you turn in!!!

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

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!