Homework 5
Short Description:
Create a network based magic eight ball.
This assignment is worth 20 points.
Goals
When you finish this homework, you should have:
- Created network based client and server software.
- Experimented with socket programming.
Formal Description
Write a program that simulates the magic eight ball.
You should provide a server program that listens at a port for tcp connections, and then services all requests for that connection. Furthermore you should log all connections, questions asked and responses given.
You should also provide a client, that connects to your server and allows the user to ask multiple questions. This should be interactive.
Input
The input to the client should be a text string. Any string other than "QUIT"
should be sent to the server. The string "QUIT" should cause the program to
terminate. You should also accept a string "HALT" which when sent to the server causes it to exit.
Questions are a single line of text terminated with a newline (enter key).
This is to make it easy to parse.
Output
Your server should accept any text string, and return one of the standard
magic eight ball responses (or if you wish, a modified version of these
responses). Remember the questions are to be yes/no questions so the answers should be positive/negative or some form of "unsure, ask again".
You should open a log file and maintain a list of connections questions and answers.
Your log file should contain the host ip address, host name and port number of the connecting
program.
Discussion
Your host should run until it receives a halt command.
Your client should run until it receives a halt or a quit command.
An example session may be as follows:
Enter your question: Is this right?
Server says: As I see it, yes.
Enter your question: QUIT
Should produce the following log file:
Connection from 147.64.242.52 (douc54.cs.edinboro.edu) port 2342
Q: Is this right?
A: As I see it, yes.
Connection from 147.64.242.177 (cslab177.cs.edinboro.edu) on port 33512
Required Files
Source code for the client and the server.
Submission
You should mail the code for the client and server to dbennett@edinboro.edu