Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write it In C Scissors beats paper ASSIGNMENT DETAILS Rock-Paper-Scissors game: This is a game usually played between two people using their hand. Each player

Write it In C

image text in transcribed

image text in transcribed

Scissors beats paper ASSIGNMENT DETAILS Rock-Paper-Scissors game: This is a game usually played between two people using their hand. Each player simultaneously forms one of three shapes - Closed fist for a rock, open palm for a paper and a V-shape using two fingers for a scissor. The game is decided as follows: Rock beats scissors, * Scissors beats paper, and * Paper beats rock This is summarized in the figure on the right. Image Ref: Enzoklop [CC BY-SA 3.0], from Wikimedia Commons Your Task: you will write simple client-server application(s) in which the client acts as Player 1 and the server acts as Player 2. The protocol between the client and server should be as follows: * The server program is started on a user-defined port. . The client program is started and connects to the server using the server IP and port number provided on the command line. The client asks the user for input. The input may either be R (for Rock), P (for Paper) or S (for Scissors). Any other input should result in an error message, asking the user to try again The user's input is sent to the server via the connected socket. The server (acting as Player 2) must decide on any one of R, P or S. How the server decides is completely up to you. For a fair game for example, you may use a random approach to decide between choosing R, P or 3 for the server. The server reads the user's input from the client socket, evaluates the outcome (Player 1 wins, Player 2 wins or a tied game), displays each players' choice and result of the game, and also sends this information (i.e. Client's choice, Server's choice and the result of the game) back to the client. * * * .The client should display the server's reply (i.e. Client's choice, Server's choice and the result of the game) to the user. The client should give the user an option to try again or quit. . Socket Programming: The steps for creating a socket on the client side are: Create a socket with the socket ) system call Connect the socket to the address of the server using the connect ) system call . Send and receive data. There are several ways to do this. You may use the read) and write ) system calls, or the send ) and recv ) system calls The steps involved in establishing a socket on the server side are as follows .Create a socket with the socket () system call .Bind the socket to an address using the bind ) system call. For a server socket on the Internet, an address consists of a port number on the host machine * Listen for connections with the listen ) system call Accept a connection with the accept () system call. This call typically blocks until a client connects with the server o Send and receive data Scissors beats paper ASSIGNMENT DETAILS Rock-Paper-Scissors game: This is a game usually played between two people using their hand. Each player simultaneously forms one of three shapes - Closed fist for a rock, open palm for a paper and a V-shape using two fingers for a scissor. The game is decided as follows: Rock beats scissors, * Scissors beats paper, and * Paper beats rock This is summarized in the figure on the right. Image Ref: Enzoklop [CC BY-SA 3.0], from Wikimedia Commons Your Task: you will write simple client-server application(s) in which the client acts as Player 1 and the server acts as Player 2. The protocol between the client and server should be as follows: * The server program is started on a user-defined port. . The client program is started and connects to the server using the server IP and port number provided on the command line. The client asks the user for input. The input may either be R (for Rock), P (for Paper) or S (for Scissors). Any other input should result in an error message, asking the user to try again The user's input is sent to the server via the connected socket. The server (acting as Player 2) must decide on any one of R, P or S. How the server decides is completely up to you. For a fair game for example, you may use a random approach to decide between choosing R, P or 3 for the server. The server reads the user's input from the client socket, evaluates the outcome (Player 1 wins, Player 2 wins or a tied game), displays each players' choice and result of the game, and also sends this information (i.e. Client's choice, Server's choice and the result of the game) back to the client. * * * .The client should display the server's reply (i.e. Client's choice, Server's choice and the result of the game) to the user. The client should give the user an option to try again or quit. . Socket Programming: The steps for creating a socket on the client side are: Create a socket with the socket ) system call Connect the socket to the address of the server using the connect ) system call . Send and receive data. There are several ways to do this. You may use the read) and write ) system calls, or the send ) and recv ) system calls The steps involved in establishing a socket on the server side are as follows .Create a socket with the socket () system call .Bind the socket to an address using the bind ) system call. For a server socket on the Internet, an address consists of a port number on the host machine * Listen for connections with the listen ) system call Accept a connection with the accept () system call. This call typically blocks until a client connects with the server o Send and receive data

Step by Step Solution

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_2

Step: 3

blur-text-image_3

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

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago