Assignment 6 CS494-unp revised: 9/16/99 Assigned: 9/28/99 Due: 6:00pm 10/8/99 Objective: TCP concurrent server Points: 40 Description: Construct a concurrent TCP knock-knock server using fork(). The server should use a port of 0 in the bind() so the kernel can assign a port to your server. Use getsockname() to find out what port number has been assigned, and then print out "Server starting on port NNNNN" so your client (telnet) will know what port number to use for testing. Your server should spawn a child process after the accept() to serve each client. You need to use signal/waitpid to manage terminated child processes. Your child process will randomly select one of the clue-response pairs from the knock-knock data base. The child process will send the "Knock. Knock." to the client and manage the knock-knock "protocol" in a helpful manner. Be sure the child process terminates on successful completion or when the client aborts/closes the connection. Just to be safe, your child process should set an alarm (alarm(120)) so that it will terminate after 2 minutes, no matter what. (You don't need to catch the alarm signal, the default action is to terminate the process -- what we want.) Use rand() to randomly select a clue-response pair. (hint: if you have N pairs, 0 to N-1, then rand()%N returns a random integer in the range 0 to N-1) Just use telnet to test your server, e.g. telnet yourhost NNNNN You should confirm you have a concurrent server by running two concurrent "telnet" tests of your server. Provide the output from your program for at least two tests. Include at least the following clue-response pairs in your data base (you may add others). You can read these in from a file when the server first starts, or hard-wire them into the source file ... whatever. boo Why are you crying? Little Old Lady I didn't know you could yodel! Atch Bless you! Turnip Turnip the heat, it's cold in here! Doris Doris locked, that's why I had to knock! Cockadoodle Not cockadoodle who, you silly chicken! Cockadoodledoo Check error status on ALL network function calls. readline() will be useful for reading the client's responses. strncasecmp() may be handy for checking the client's responses. Do NOT use any of the Stevens' libraries nor his wrapper include file. Optional: please indicate amount of time required to complete assignment. Use ~dunigan/cs494-unp/494submit to submit your source files and output. See http://www.cs.utk.edu/~dunigan/cs494-unp/policy.txt