Assignment #1: Echo Server Program --------------------- The goal of this project is to let student get familiar with basic socket programming. The program must run on odin, and compile on odin. DESCRIPTION ------------------ The assignment requires you to write two programs (echoClient and echoServer) to demonstrate communication between two processes using TCP socket. The echoServer program should take a port number (for example 6789) as the input: $echoServer 6789 The echoClient program should take the server IP address (127.0.0.1) and the server port as the input: $echoClient 127.0.0.1 6789 The echoServer opens a socket and waits requests from the user specified port. (Make sure checking the bind result. You will very likely have some programs by you or others occupied the port already). When a connection is sucessfully created, the echoServer read in what data from the socket, and echo it back by writing "Echo: " where "input strings" are whatever data the echo server reads in. The echoClient once starts to run, it opens a socket to connect to the echoServer. Once it connects to the server, it sends a string to the server, and then reads from the reply from the server, and print it out. The goal of this assignment is to let you start to practice socket programming. Supporting for concurrent request is optional. Below is a sample structure of the echo server that support concurrent requests with multiple processes. void echo (int sid, char *str); /* echo: copy the input string str to a new buffer, * and write the buffer to the sockek indicated by sid */ int main (int argc, char **argv){ int sockid, s; /* take in user specified port number from commandline argument */ /* set up socket */ while ((s=accept(sockid, ... ))>0) { if (fork()==0){ /* Child process */ read(s, buf ....); echo(s, buf); exit(); } } } Notice that some unix systems do not automatically search for the socket related library. You need to use "-lsocket -lnsl" to indicate that socket and internet related libraries are required by your program. For example, to compile your programs on solaris, use "gcc(or g++) your_program -lsocket -lnsl" REQUIREMENTS: ------------------ o You must submit at least the following files (i.e., all the files necessary to compile your program): (Assuming you are using c to program. If you use otherfiles, submit the coresponding files). README.txt echoserver.c/cpp echoclient.c/cpp Makefile The submission process will be announced in class later.