import java.io.*;
import java.net.*;

class HpEchoSocketTest {

       Socket s;
       String hostname;
       int port;
       PrintWriter out = null;
        BufferedReader in = null;


       public void readAndPrint() throws Exception {
              InputStream ins;
              OutputStream os;

              BufferedReader stdIn = new BufferedReader(
                                   new InputStreamReader(System.in));
                String userInput;

                    while ((userInput = stdIn.readLine()) != null) {
                        out.println(userInput);
                        System.out.println("echo: " + in.readLine());
                    }
              stdIn.close();
       }

///////////////////////////////////////////////


       public HpEchoSocketTest(String name, int port) {
              hostname = name;
              this.port = port;
              try {
                     s = new Socket(hostname, port);
                     out = new PrintWriter(
                            s.getOutputStream(), true);
                        in = new BufferedReader(
                              new InputStreamReader(
                                          s.getInputStream()));
                     readAndPrint();
                     in.close();
                     out.close();
              } catch (Exception e )       {
                     System.out.println(e.toString());
                     System.exit(1);
              }
       }

       public static void main(String[] args) {
              HpEchoSocketTest st;
              String host = "holly";
              int    port = 7;

              st = new HpEchoSocketTest(host, port);
       }

}

