Write a Client program that communicates with the Server (host) running on UWEX-APC400-100 (Note: Reachable only through

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a Client program that communicates with the Server (host) running on UWEX-APC400-100 (Note: Reachable only through

Post by answerhappygod »

Write a Client program that communicates with the Server (host)running on UWEX-APC400-100 (Note: Reachable only through VirtualLab) on port 5520. You MUST use Java JFrame and meet therequirements described below.
Write A Client Program That Communicates With The Server Host Running On Uwex Apc400 100 Note Reachable Only Through 1
Write A Client Program That Communicates With The Server Host Running On Uwex Apc400 100 Note Reachable Only Through 1 (181.52 KiB) Viewed 30 times
Program Requirements 1. The Server is running a proprietary protocol called Knock Knock Protocol. It will only respond when your Client is following the protocol correctly. When your Client is successfully connected to the Server, you must follow the protocol as follows: o The first message sent to the Server must be "Knock Knock"; this is like saying hello to the Server. The message is not case- sensitive on the Server side. The Server will send "who's there?" back to the Client, but if you send anything else, the Server simply doesn't understand and will send "???". o Next, the Client must identify itself to the Server in response to the message "who's there?". For example, "Banana". After that, the Server will send "Banana who?" back to the Client. o When the Server sends "Banana who?", the Client can send a knock-knock joke to the Server. The Server is not very smart, but it is very kind, so whatever joke you send, it will always LOL! o Because the Server is very accommodating, the Client can tell it another knock-knock joke even if the previous one is not funny. In this case, the Client must send "Knock Knock" again! o The Client can send a "quit" message anytime to disconnect from the Server, who will send a "Good Bye!" message back to the Client. The "quit" message is not case-sensitive. 2. Your GUI (JFrame) should include the following Java Swing components: o A JLabel and a JTextField for entering the Server address; set text to UWEX-APC400-100. o A JLabel and a JTextField for entering the port number; set text to 5520. o Have a Connect/Disconnect JButton, and set text to "Connect". When the Connect button is clicked, connect to the port and server specified. Also, change the text to "Disconnect". When Disconnect is clicked, close the connection and change the text back to "Connect". If the connection dies for any reason, the button must display "Connect". And, whenever the Client is connected to the Server, the button must display "Disconnect". Make sure your Connect/Disconnect button is in the correct state. o A JLabel, JTextField, and a Send button for sending a message (String) to the Server. o A JLabel and a read-only JTextArea (in the Design view in NetBeans, uncheck the "editable" box) for displaying messages. DO NOT print anything to System.out. Use the append() method of JTextArea to display all messages (including the communications between the Client and the Server), error messages, and the connection status (either connected to... or disconnected...). DO NOT CLEAR the messages in the JTextArea. • Example GUI of the Program 1 Knock Knock Client 3. Your program must not crash under any situation and must always be in a sane state. You must try-catch everything and print out appropriate error messages identifying the specific exception. 4. You must schedule a demo time with me. 5. Test your program using the Program 1 Test Case document before you submit. 6. You must zip all files for Program 1 and submit the zip file to Program 1-Zip File by the due date. Program Hints 1. Design the GUI of your client program, and set the default host IP and port number. 2. Import java.io.* and java.net.* 3. Declare three objects with Socket, PrintWriter, and Buffered Reader, so these objects are visible throughout the program. 4. Code the "connect" button (connectButtonAction Performed() method): o If the client is currently disconnected (the text of the button is "connect"), instantiate the objects declared in step 3. Note that you need to use the getText() method to get the host IP address and the port number in order to instantiate a socket object. o If the client is currently connected (the text of the button is "disconnect"), close the socket and I/O objects and set the text of the button to "connect". Note that you MUST display a disconnected message in the text area. o Remember to set the correct text for your connect button (either "connect" or "disconnect"). 5. Code the "Send" button (send ButtonAction Performed() method): o If, for some reason, you get disconnected, you won't be able to send messages to the server. Therefore, you must deal with the exception. o Display the message you sent in the text area in the following format: "Client: .......... Write the message to the socket (printwriterObj.println() method) and wait for the server's response (bufferedreaderObj.readLine() method). o If you send "quit" and the server replies "Good Bye!", remember to set the text of the connect button to "connect".
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply