Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Electrical Engineering questions