Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Debug following Echo server and client program. Assume all packages are imported. No indentation errors. Do not focus on upper or lower cases.
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
SERVER CODE import javanet import javaio import javautil class Server public static final int SERVER...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started