A protocol defines the format of messages exchanged between two computers that allow the computers to communicate with one another. The table below defines a protocol for a simple guessing game (\n indicates a newline). Description Start or restart a new game. Quit the game. Guess a number. Bad request. Request (from client) restartin quit\n guess #\n Anything other than the above. Response (from server) restarted\n game_over\n i. ii. toolow\n toohigh\n correct\n out_of_guesses\n error\n For this assignment, you will implement a networked guessing game. The client will connect to a server, at which point a new game will begin. The client will have a limited number of guesses to guess a number. The client may start a new game or quit at any time. Hint use PrintWriter and BufferedReader to send/receive lines of text terminated by newlines. 1. Create a GuessingGameServer class that implements the server-side of the protocol. a. Wait for a client to connect on port 6355. b. In a loop, read requests from the client and respond to each request accordingly. c. For each new game, a new secret number between 1 and 100 must be generated. The client will have 6 guesses to guess the number. Respond with the appropriate message from the above table. If the client continues to guess after running out of guesses, treat it like a bad request. iii. The client can restart at any time (even in the middle of a game). d. If the client quits, the program should exit. 2. Create a Guessing GameClient that provides a command-line interface for the human user to play a game. a. The hostname of the server is a command-line argument. b. Connect to port 6355. c. Prompt the user to enter guesses. d. Print the appropriate output to the user (e.g. "Too low!", "Too high!", "Out of guesses!"). e. If the user quits, send the quit message to the server, close the socket, and exit the program.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Please implement in java code with screenshots of output

A protocol defines the format of messages exchanged between two computers that
allow the computers to communicate with one another. The table below defines a
protocol for a simple guessing game (\n indicates a newline).
Description
Start or restart a new game.
Quit the game.
Guess a number.
Bad request.
Request (from client)
restartin
quit\n
guess #\n
Anything other than the
above.
Response (from server)
restarted\n
game_over\n
toolow\n
toohigh\n
correct\n
out_of_guesses\n
error\n
For this assignment, you will implement a networked guessing game. The client will
connect to a server, at which point a new game will begin. The client will have a limited
number of guesses to guess a number. The client may start a new game or quit at any
time. Hint: use PrintWriter and BufferedReader to send/receive lines of text
terminated by newlines.
1. Create a GuessingGameServer class that implements the server-side of the
protocol.
a. Wait for a client to connect on port 6355.
b. In a loop, read requests from the client and respond to each request
accordingly.
c. For each new game, a new secret number between 1 and 100 must be
generated. The client will have 6 guesses to guess the number.
ii.
Respond with the appropriate message from the above table.
If the client continues to guess after running out of guesses, treat it
like a bad request.
iii.
The client can restart at any time (even in the middle of a game).
d. If the client quits, the program should exit.
2. Create a Guessing GameClient that provides a command-line interface for the
human user to play a game.
a. The hostname of the server is a command-line argument.
b. Connect to port 6355.
c. Prompt the user to enter guesses.
d. Print the appropriate output to the user (e.g. "Too low!", "Too high!", "Out of
guesses!").
e. If the user quits, send the quit message to the server, close the socket,
and exit the program.
Transcribed Image Text:A protocol defines the format of messages exchanged between two computers that allow the computers to communicate with one another. The table below defines a protocol for a simple guessing game (\n indicates a newline). Description Start or restart a new game. Quit the game. Guess a number. Bad request. Request (from client) restartin quit\n guess #\n Anything other than the above. Response (from server) restarted\n game_over\n toolow\n toohigh\n correct\n out_of_guesses\n error\n For this assignment, you will implement a networked guessing game. The client will connect to a server, at which point a new game will begin. The client will have a limited number of guesses to guess a number. The client may start a new game or quit at any time. Hint: use PrintWriter and BufferedReader to send/receive lines of text terminated by newlines. 1. Create a GuessingGameServer class that implements the server-side of the protocol. a. Wait for a client to connect on port 6355. b. In a loop, read requests from the client and respond to each request accordingly. c. For each new game, a new secret number between 1 and 100 must be generated. The client will have 6 guesses to guess the number. ii. Respond with the appropriate message from the above table. If the client continues to guess after running out of guesses, treat it like a bad request. iii. The client can restart at any time (even in the middle of a game). d. If the client quits, the program should exit. 2. Create a Guessing GameClient that provides a command-line interface for the human user to play a game. a. The hostname of the server is a command-line argument. b. Connect to port 6355. c. Prompt the user to enter guesses. d. Print the appropriate output to the user (e.g. "Too low!", "Too high!", "Out of guesses!"). e. If the user quits, send the quit message to the server, close the socket, and exit the program.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY