1. Debug following Echo server and client program. Assume all packages are imported. No indentation errors....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Debug following Echo server and client program. Assume all packages are imported. No indentation errors. Do not focus on upper or lower cases. Hint: Three bugs in each file java file. Below are two programs EchiServer.java and EchoClient.java. EchoServer.java public class Main { 11 public static void main(String[] args) { while (ServerSocket serverSocket-new ServerSocket (5000)){ (true){ Socket socket serverSocket.accept(); EchoText echoText new EchoText (socket); echoText.finish(); new Echo Text (serverSocket.accept()).start(); }catch (IOException e) { System.out.println("Server exception "+e.getMessage()); EchoClient.java public static void main(String[] args) { try ( Socket socket = new Socket ("localhost", 5000); try ( socket.setSoTimeout(5000); Buffered Reader echoes new Buffered Reader(new InputStreamReader(socket.getInputStream())); PrintWriter stringToEcho= new Printwriter (socket.getOutputStream(), 1); Scanner - new scanner(System.out); String echoString; do ( System.out.println("Enter string to be echoed: "); stringToEcho.println(echoString); if (lechoString.equals("exit")) { echoString scanner.nextLine(); String response echoes.readLine(); System.out.println(response); } while (!echoString.equals("exit")); } catch (Throwable var8) { try ( socket.close(); } catch (Throwable var7) ( var8.addSuppressed (var7); } throw var8; socket.close(); } catch (SocketTimeoutException var9) { System.out.println("The socket timed out"); } catch (IOException var10) ( System.out.println("Client Error: " + var18.getMessage()); } Output: Received client input: hello Enter string to be echoed: hello The socket timed out Javaagente 1. Debug following Echo server and client program. Assume all packages are imported. No indentation errors. Do not focus on upper or lower cases. Hint: Three bugs in each file java file. Below are two programs EchiServer.java and EchoClient.java. EchoServer.java public class Main { 11 public static void main(String[] args) { while (ServerSocket serverSocket-new ServerSocket (5000)){ (true){ Socket socket serverSocket.accept(); EchoText echoText new EchoText (socket); echoText.finish(); new Echo Text (serverSocket.accept()).start(); }catch (IOException e) { System.out.println("Server exception "+e.getMessage()); EchoClient.java public static void main(String[] args) { try ( Socket socket = new Socket ("localhost", 5000); try ( socket.setSoTimeout(5000); Buffered Reader echoes new Buffered Reader(new InputStreamReader(socket.getInputStream())); PrintWriter stringToEcho= new Printwriter (socket.getOutputStream(), 1); Scanner - new scanner(System.out); String echoString; do ( System.out.println("Enter string to be echoed: "); stringToEcho.println(echoString); if (lechoString.equals("exit")) { echoString scanner.nextLine(); String response echoes.readLine(); System.out.println(response); } while (!echoString.equals("exit")); } catch (Throwable var8) { try ( socket.close(); } catch (Throwable var7) ( var8.addSuppressed (var7); } throw var8; socket.close(); } catch (SocketTimeoutException var9) { System.out.println("The socket timed out"); } catch (IOException var10) ( System.out.println("Client Error: " + var18.getMessage()); } Output: Received client input: hello Enter string to be echoed: hello The socket timed out Javaagente
Expert Answer:
Answer rating: 100% (QA)
SERVER CODE import javanet import javaio import javautil class Server public static final int SERVER... View the full answer
Related Book For
Auditing a risk based approach to conducting a quality audit
ISBN: 978-1133939153
9th edition
Authors: Karla Johnstone, Audrey Gramling, Larry Rittenberg
Posted Date:
Students also viewed these programming questions
-
Compare and contrast nonprofit management with for-profit business management. In your view, what are the three most important differences that effective managers should be aware of?
-
An appropriate structure for large-scale distributed systems is as multiple, independently administered, firewall-protected, domains. Examples are a national health service, a national police service...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Explain what quality management knowledge and skills an auditor should possess when auditing
-
Explain the symmetry criteria that allow a molecule to be polar?
-
Suppose we introduce a new criterion, administrative feasibility, for evaluating environmental policies in developing countries. How might this affect choices among different types of policies?
-
Meddevco (name changed) is a large multinational corporation that operates in the medical devices sector. The firm employs around 33,000 people in five divisions and has operations in 120 countries....
-
Hiatt Company sells automatic can openers under a 75-day warranty for defective merchandise. Based on past experience, Hiatt estimates that 3% of the units sold will become defective during the...
-
Affordable Home Purchase Data Maximum allowable monthly housing expenditure (%) 28% of monthly gross income Maximum total affordable monthly debt payments (%) Down payment (%) 36% of monthly gross...
-
A mixture of three amino aids is separated by gel electrophoresis. The three amino acids are glycine, valine and phenylalanine (Figure 27.14). a. The electrophoresis is carried out in a buffer...
-
Topic: We have all heard the saying that "you do not get a second chance to make a first impression". Do you agree with the statement above? Briefly explain why or why not. Elaborate on the five best...
-
Data science palindrome.py Using import sys: .Create a program, palindrome.py, that has a function that takes one string argument and prints a sentence indicating if the text is a palindrome. The...
-
The Trespasser physics engine simulated rigid body box-shaped colliders and allowed the game player to easily build complicated structures such as a staircase made of crates.
-
W What was the average speed maintained by Dick Rutan and Jenna Yeager on their non-stop flight around the world?
-
1. Describe why effective communication can happen even without agreement between the communicating parties. 2. Describe the environmental factors that most directly influence the human resource...
-
Select an online retailer and spend time researching their website. A 150-200 word analysis about web analytics to the website you select. Please infer one or two conversion goals that the website...
-
Claire Santos opened Little Steps and Sway Dance Studio which offers yoga, ballet, and stretch classes for children. The following are her transactions for March 2022: 1 Opened a bank account with a...
-
Consider the following cash flows in Table P5.5. (a) Calculate the payback period for each project. (b) Determine whether it is meaningful to calculate a payback period for project D. (c) Assuming...
-
Assume that an auditor wishes to use analytical procedures as a substantive procedure. Indicate how substantive analytical procedures could be used in assisting the auditor in testing the following...
-
Refer to the Auditing in Practice feature "Performing Appropriate Substantive Procedures in the Revenue Cycle: The Case of Kyoto Audit Corporation." What substantive procedures did Kyoto not perform...
-
The following long-term debt documentation (indexed K-l), and presented on the next page, was prepared by client personnel and audited by AA, an audit assistant, during the calendar year 2013 audit...
-
A company expects to receive which of the following benefits when it uses its budgeting process? a. The planning required to develop the budget helps managers foresee and avoid potential problems...
-
A direct materials budget would be used in which of the following types of companies? a. Service b. Merchandising c. Manufacturing d. All of the above
-
A disadvantage to merchants from accepting debit and credit cards would be a. lost sales. b. transaction fees. c. bounced checks. d. longer time to receive cash.
Study smarter with the SolutionInn App