Question: Once a connection has been achieved between the client program and the associated server thread and both programs have set up their respective socket streams
Once a connection has been achieved between the client program and the associated server
thread and both programs have set up their respective socket streams for IO the game begins
with the server thread generating a random sequencecode of colored pegs. Each peg is one
of six colors R red Y yellow G green B blue W white or O orange Repeated colors
are allowed within the codesequence So for example, our game sequence might be RGGW
Each turn in the game consists of the player attempting to guess the color sequence. The
client program will prompt the user to enter their guess and assuming no errors will forward
the guess to the server thread via the output stream of the socket. Once a guess has been
received on the server side, the server will respond by providing an indication of how close the
guess was. The server encodes its response by reporting a combination of of the following
values. P correct color and position C correct color wrong position or a string of blanks
indicating neither correct color nor correct positions were found. For example, suppose the
program chose the code RGGW red green, green, blue If the user were to guess WBGG then
the program would respond with CCP indicating that two of the guessed pegs are correct in
color but not position and a third peg is both the correct color AND in the correct position. Note
that the represents a blank space. All replies from the server will consist of a character
string. If the server thread is ever sent a correct guess, then it will reply with the string PPPP
and will cease its execution. When the client receives the PPPP string it will report the win to
the user along with the total number of guesses that the user provided during the game.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
