Connecting to the echo port (7)

The echo port 7 will return a datagram that contains the exact contents of what was sent to it.
On many systems, this port is being disabled, fearing hackers may use it to perform a denial-of-service attack of some sort.

Just open a socket and write a line. If the port is enabled, the return will be the exact line.

import java.util.*;
public class EchoClient {
   public static void main(String args[]) {
      if (args.length != 1) {
         System.out.println("java EchoClient <server>");
      try {
         Socket socket = new Socket(args[0], 7);    // 7 is echo port
         BufferedReader br = new BufferedReader(
                                new InputStreamReader(socket.getInputStream()));
         // true = autoflush
         PrintWriter pw = new PrintWriter(
                                new OutputStreamWriter(socket.getOutputStream()), true);  
         pw.println("Hello, world!");
         String ret = br.readLine();
      catch(Exception e) {

java EchoClient www.compapp.dcu.ieoutputs:

Hello, world!