Assignment 0
Your first assignment is to build a server capable of receiving text messages
from clients. The server should print these text messages on standard output,
but should not print any other messages such as debug information.
From the server perspective, a message corresponds to the data received from a
particular client during a communication session with that client. The server
should be listening for text messages to a port known to the clients. The
server should be able to receive text messages from multiple clients. When
multiple clients simultaneously try to send text messages to the server, the
server should print them one at a time (in any order). Note that you don't
have to implement an event-driven or multi-threaded server. Serving one
client at a time is enough.
You should also implement a client to test the server. The client should
receive the text message from standard input. The end of the message is marked
by a control sequence which corresponds to hitting >ENTER< twice. This control
sequence is also an instruction for the client to exit. This control sequence
should not be transmitted. Also, if your client reads the text message from a
file via pipes, and reaches EOF without seeing the control sequence, then the
client should still transmit the message and exit.
This assignment should be completed in ANSI C or C++. It should compile and run
without errors in the FC 010 cluster producing two binaries called server and
client. The server should take as its first argument the port to listen to. The
client should take as its first argument the name of the host that the server
is running and the port that the server is listening. If the server cannot bind
to the port that you specify, a message should be printed on standard error and
the program should exit. You shouldn't assume that your server will be running
on a particular IP address, or that clients will be coming from a predetermined
IP address. Both the client and server should generate an appropriate error message and terminate when given invalid arguments.
You should test your code with long text messages (of size at least 20KB), not
just short ones. You can use pipes to redirect the standard input of the client
and standard output of the server. You should also test your code with multiple
clients. (at least up to 5 simultaneous clients)
The deliverables are two files: "server.c" and "client.c" implementing the
server and client as described above and a makefile for producing the
executables.