

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CSC 2400 Computer Systems Fall 2008
Dr. Tom Way
About An Echo server is a program that listens for incoming network messages and sends them back to the client that sent them as a way to test the functioning of network programs. This lab will give you some experience with network programming, in this case using Java by running and then modifying an Echo server and client combination.
Setup
Running You will now run the EchoServer in one window while running the EchoClient in another. To do this:
Modifications Now, you will modify the EchoServer to be more useful.
handleInput method from EchoServer.java
// Handles input received from EchoClient, and returns // true if EchoServer can handle input, or false if it // cannot (typically meaning it should exit). public boolean handleInput(String line) throws IOException { String echoMsg; String printMsg = "Message received on port "+port+" was: " + line;
// Handle to case where the client says "bye" if ( (line == null) || line.equals("bye")) { System.out.println("Bye."); return false; } // Default case else { echoMsg = "Server heard port "+port+" say: " + line; }
// Write out a local message System.out.println(printMsg);
// Echo the message back to the client networkPout.write(echoMsg+"\n"); networkPout.flush();
return true; }