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
-
Based on the information provided, write a simple work flow analysis listing inputs, activities, and outputs of an Amazon distribution center?
-
The following information is for Neopolitan Ltd. in July: 1. Cash balance per bank, July 31, $8,833 2. Cash balance per books, July 31, $7,190 3. Bank service charge, $24 4. Deposits in transit,...
-
Using the information in the below table, prepare a classified balance sheet for Arrow Company as of December 31, 2014 and December 31, 2015, along with multi-step income statements for the years...
-
Air pollution control specialists in southern California monitor the amount of ozone, carbon dioxide, and nitrogen dioxide in the air on an hourly basis. The hourly time series data exhibit...
-
D Required information [The following information applies to the questions displayed below.] Iguana, Incorporated, manufactures bamboo picture frames that sell for $25 each. Each frame requires 4...
-
1. Is Rapailles code system a short-cut code to understanding the complexities in culture and a way to make market research easier? Or is it a superficial hoax sold by a charlatan? 2. As a manager,...
-
ex dx In x dx = e (a) e-e? (b) 2+ e-e? (c) 2e-e? (d) 1 e-e? (e) none of these
-
Consider the energy levels for a hydrogen atom, listed in the table below. Each energy represents what is required for the negatively charged electron to escape. For example, if the electron were in...
-
Tom wants to avoid any accidents on the work floor of his factory. If an accident does occur, it would cost him $500,000 in damages. Installing safety equipment would decrease the probability of an...
-
Cullumber Co. manufactures low-price, no-frills appliances that are in great demand for rental units. Pricing and cost information on Cullumber main products are as follows: Item Standalone Selling...
-
What role does globalization play in reshaping social structures, cultural practices, and identity formations on both local and global scales, particularly in the context of migration,...
-
Many presidents have been lawyers, though George W. Bush was a businessman, Ronald Reagan was an actor, and Jimmy Carter was a naval officer and owned a peanut warehouse. What advantages might these...
-
Supply a fool-proof recipe for making 5.000 L of 0.01234 M NaOH solution. You have access to a solution of NaOH in water which was made by adding 45.67 g NaOH to a 2.000 L volumetric flask and making...
-
You are planning to purchase your first home five years from today. The required down payment will be $50,000. You currently have $20,000. but you plan to contribute $500 each quarter to a special...
-
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...
-
As long as human _________ exceed available _________, scarcity will exist.
-
The scarce resources that are used in the production of goods and services can be grouped into four categories: _________, _________, _________, and _________.
-
Well-defined property rights encourage a. investment. b. innovation. c. conservation. d. exchange. e. economic growth. f. all of the above.
Study smarter with the SolutionInn App