Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Carefully read the shared client.java and server.java files along with the comments placed per command. Run the server project first, then run the client project.

image text in transcribed
image text in transcribed
image text in transcribed
Carefully read the shared client.java and server.java files along with the comments placed per command. Run the server project first, then run the client project. These projects create a chat between the client and the server. Through the terminal window of the client, you can start writing some statements, and on clicking enter, you should find these statements on the terminal of the server side along with responses back from the server displayed on the client side. This chat will keep on until the client sends "exist" as a command and clicks enter, this will terminate the connection established as well as the read and write streams on the fwo sides. Taskl description ( 5 points): In this assignment, you will extend these shared files to implement an interactive two-tier communication application using network sockets. Usually, the client and server applications reside on two different devices (e.g., two computers, a smartphone and a computer). But, to keep this lab simple, you can run both client and server applications on the same computer. - If you are running the client and server on the same device, the IP of the server will be "localhost" or "127.0.0.1" - If you are running the client and server on two different devices over the same network (e. g. your home network), how to know. the IP of the server? On the server side, 0. open a terminal (if you are using Linux or Mac) and type "ipconfig getifaddr en0" - open a CMD (if you are using Window) and type "ifconfig" then search for IPv4 - If you are running the client and server on two different devices over different networks - check the VPN section below. The client hosts the user-interface layer where the user can send command(s) to the server. The server hosts both the processing and data layers to handle the incoming commands from the client side on stored data. The data layer at the server side keeps a dynamie list (ArrayList) of integers (initially empty) named as inputValues to handle (add/remove) data to/from the user. The user at the client side enters a command through the terminal (e.g. of your IDE) and then waits for a response back from the server to be able to enter another command. The following table shows the different supported commands that the user can send to the server side, along with the proper handle from the server side and expected responses. The client side should print a list of the supported commands to the user to help them write the correct formatted command. If the user sends any other command or a supported command, but in a different format, the server should ignore the received message and respond with "umsupported command " without exiting either the client or the server. A command from the client to the server is a JSON object, with a unique identifier as the key and the actual instruetion as the value, A response from the server to the client is also a JSON object, with the identifier of the instruetion as the key and the result as the value. For example: - If the user wants to add the number 80 to the server's list, the user types "Add: 80" and clicks enter. - The client builds JSON-based command: \{"Instruction 1 ": "Add 807}. - The server executes the instruction and responds with the following JSON-based responsie: ("Instruction 1"; "added sacoessfully" 3 ? - If the user wants to display the sorted version of the values from the server's list, the user types "Sort A" and clicks enter. - The client builds the following JSON based command: ("Instruction 2"I "Sort_A" - The server then execules the instruction and responds with the following ISON-based response: ("lnstruction 2 ": "The soated lie is (10,20,30,40}) Iark? dereription ( 5 points): Your design in taskl shoald be more efficitet allowing the client to batch owe er more commands and the server to batch the eorrespooding response(c) - we noed 10 use JSON-formathed messages. The client-server commanieation sheculd send an array of 150N-objects and get JSON responses. For example: - Suppose the user wants to add mumber 80 then sort the array. The aser types "Add: 80; Sort A " and cheks enter. - The client builds the following JSON-baced artay of comimands: [f "Instruction 1", "Ad4: 80. I. "Instructice 22n, "Sort A")] - The server then executes the instructions cone by one and responds with the following 150N based array of rerponses: Eurther Resuarest: The client creates 150N objects for commands and sends them as strings to the strver aide. The server side comvers the receivod strings to JSOS objects. The server side creates 190N objects for fesponses and iends them as srings to the olient kide. The slient diaplays the responses to the user. Let's assume the aser is frirndly enough nat to place the evit camband in ahe middle ef the commands" arrey te the server. Use the 3SON bibrary yoe find apropriale (e.gr, hripolwww javazs com Code/lasy Dowelautjavajwonjar hem. De enewgh march to frarn about wsing the J50, herary in fave. Sockets we discussed assume the communicating computers are on the same network and use local IPs. If you are working in a group, with a team mate is developing and running the client and the other mate is developing and running the server side most probably you are working in two different networks - thus your team needs a virtual private network, kind of network that allows two computers on two different networks to see each and communicate with each other. For this assignment, you can use LogMeln Hamachi (hitps://vpn.net), download, install, then run - create a network and share the network ID and password with your teammate to join

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

=+9. Prove (2) and (4) of Theorem 7.6 .18.

Answered: 1 week ago

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago

Question

=+ 4. Why should policymakers think about incentives?

Answered: 1 week ago

Question

=+ 2. What is the opportunity cost of seeing a movie?

Answered: 1 week ago