The Forking Spelling Checker

You mission is simple. You will write a server. This server will accept multiple clients. Each client will send you one or more words. You will check to see if those words appear in the dictionary. You will send 'yes' or 'no' depending on what you find.

Outline of the program

Make a server style socket
Wait for a connection
Fork
	If you are the child
		Read and check lots of words, printing answers
	If you are the parent
		loop back

The key to all of this is the 'fork' command. Please read the fork man page. You can find my notes on fork here.

You can find how to make a server style socket here.

You can find a dictionary of words at /usr/share/dict/words. The following code might help you remember how to use files.

        ifstream infile("/usr/dict/words", ios::in);
        if (!infile) {
              perror("Unable to open file");
              exit(1);
        }
        while (infile >> word) {
              cout << "I read " << word << endl;
        }

Grades

1 -- Can make a server style socket
1 -- Can accept a connection from the client
1 -- Can fork correctly
1 -- Can look up a single word
1 -- Can look up multiple words
1 -- Uses a binary search to do the lookup (or something fast)
1 -- Rejects all connections from some specified IP number
-0.5 -- Each day after Tue Sep 28th