Lab 11

First, make a directory and put in it server.c, client.c, and Makefile from http://www.calvin.edu/~lave/333lab

Next, compile the C programs by typing "make".

Now, run the server by typing ./server 23001. In a separate window type ./client localhost 23001. What does this server do?

Run the server on various machines and have others (including different groups) run the client to contact your server. Try it 3 or 4 at a time.

Run netstat -t and see what connections you can see on the server.

Take the following challenge: change the server to an echo server, ie, have it send back the exact message it receives. To do this:

  1. in client.c right after the connect function is called, add a call to scanf (scanf("%s",buf)) and a send right before the receive.

  2. in server.c right after the accept add a forever loop in which you recv and send. Take out the stuff about the number of visits.

  3. The results will not be perfect, but you should be able to send one message from the client to the server and get the same message, more of less, back. A good suggestion would be to break; out of that loop if the string received is "bye". You would do that with if (!strncmp(buf,"bye",3)) break;.