Question: Code in C . Create a hangman game in C using named pipes and processes. Thegame's server is ran through using gameserver.c and the client

Code in C .

Create a hangman game in C using named pipes and processes. Thegame's server is ran through using gameserver.c and the client isran using gameclient.c. I have provided the pseudocode for eachbelow.

gameserver.c should run the server functionality. It loads allthe dictionary words from dictionary.txt as part of thesetup and waits for input through the named pipe /tmp/NETID. Foreach request comes through the pipe, server should fork a process -Child process should send its own unique pipename to the client andstart the hangman game! Parent process proceeds to wait for newrequests. This setup enables the server to support any # of clientsin parallel!

gameclient.c is a thin client program that gets the user inputand passes to the server and shows the reply in the screen. Here isa sample I/O for the client.

(Guess) Enter a letter in word ******* > p (Guess) Enter a

Pseudocode for gameclient.c

/* make up unique pipename

* send it to the server

* get another unique pipename from the server

* repeat

* get the starred word from the new pipe

* display to the user

* get the user's guess letter

* send to the server

*/

Pseudocode for gameserver.c

/*

* read dictionary file to array of words & get ready to playthe hangman!

* wait for a request to come in (unique pipename)

* respond with another unique pipename

* send a bunch of stars (indicating the word length)

* fork() to enable games to proceed in parallel.

* for each guess the client sends in, respond with a message

* and send updated display word.

* /

(Guess) Enter a letter in word ******* > p (Guess) Enter a letter in word p******> r (Guess) Enter a letter in word pr**r** > p p is already in the word (Guess) Enter a letter in word pr**r** > 0 (Guess) Enter a letter in word pro*r** > g (Guess) Enter a letter in word progr** > n n is not in the word (Guess) Enter a letter in word progr** > m (Guess) Enter a letter in word progr*m > a The word is program. You missed 1 time

Step by Step Solution

3.41 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!