Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two programs that play a trivia game using a socket. Include examples of your program output in a report. If you wish, you may

Write two programs that play a trivia game using a socket. Include examples of your program output in a report. If you wish, you may use a fixed port number and IP address of 127.0.0.1. Create separate server and client programs (two .c files) according to the following design requirements:

  • The server is assumed to be executed before the client.

  • The server creates a socket. When the client connects, the server writes the trivia question and

    attempts to receive the answer. Note that accept and read are blocking functions, as explained

    in class.

  • The client, which is started after the server, reads and displays the question.

  • The client allows the user to type an answer and writes it to the socket.

  • The server reads the clients answer, displays it, and compares it to the correct answer (which is

    known by the server). The server writes the result message (correct or incorrect) to the socket.

  • The client reads the result and displays it to the user.

    Below are examples of how your output might look (user input is in bold). The trivia question in both examples is What is the capital of Greece?. In example #1, the clients user types the correct answer Athens. In example #2, the clients user types the incorrect answer London.

Server example #1:

Sent question. Answer received: Athens 

Server example #2:

Sent question. Answer received: London 

Client example #1:

What is the capitol of Greece? 
Waiting for result... Correct! 

Client example #2:

What is the capitol of Greece? 
Waiting for result... Wrong 

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

=+Show that un is finitely additive and countably subadditive on o.

Answered: 1 week ago

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago