Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java Write a client program and a server program to implement the following features via using the UDP service. Client Program: 1. Display a

In java Write a client program and a server program to implement the following features via using the UDP service.

Client Program: 1. Display a message to ask the User to input the DNS or IP of the machine on which the Server Program runs and read this user input as a string.

2. Display the following table on the standard output:

Item ID Item Description

00001 New Inspiron 15

00002 New Inspiron 17

00003 New Inspiron 15R

00004 New Inspiron 15z Ultrabook

00005 XPS 14 Ultrabook

00006 New XPS 12 UltrabookXPS

3. Display a message on the standard output to ask the User to input an Item ID and validate the user input. If the input is not a valid Item ID, ask the User to re-type it.

4. Once getting a valid item ID from the User, send a request message including this Item ID (e.g., 00005 or 00005) to the Server program to ask for a quote, and record the local time right before sending such request.

The user input read in Step 1 is the destination address to which this request message is sent.

5. Receive and interpret the response from the Server program, get the local time right after such response is received, and display the following information on the standard output, (e.g., if 00005 were provided by the User earlier on)

Item ID Item Description Unit Price Inventory RTT of Query

00005 XPS 14 Ultrabook $999.99 261 ms

where RTT of Query is the difference between the time in Steps 5 and 4 in milliseconds.

6. Display a message on the standard output to ask the User whether to continue. If yes, repeat steps 2 through 5. Otherwise, close the socket and terminate the Client program.

Server Program: 1. Maintain the following information using an appropriate data structure of your choice (i.e., an array of a Class you defined).

You do not have to place it in a file although you certainly can if you like.

Item ID Item Description Unit Price Inventory

00001 New Inspiron 15 $379.99 157

00002 New Inspiron 17 $449.99 128

00003 New Inspiron 15R $549.99 202

00004 New Inspiron 15z Ultrabook $749.99 315

00005 XPS 14 Ultrabook $999.99 261

00006 New XPS 12 UltrabookXPS $1199.99 178

2. Wait for receiving a packet from a Client.

3. Once a packet is received from a Client, retrieve the information relevant to the requested Item ID from the data structure you used in Step 1 and send back such information to the Client.

4. Repeat Steps 2 and 3 infinitely until an exception is caught.

5. Close the datagram socket.

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

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

i need correct answrrs 4 4 2 .

Answered: 1 week ago