import java.io.*; import java.net.*; class EchoClient { public static void main(String[] args) throws IOException { Socket t = new Socket(args[0], 8189); //8189 is chosen by the programmer String str; DataInputStream is = new DataInputStream(t.getInputStream()); PrintStream out = new PrintStream(t.getOutputStream()); DataInputStream in = new DataInputStream(System.in); System.out.println("Hello! Enter BYE to exit.\r"); boolean more = true; while (more) { System.out.println("type in a line : "); str = in.readLine(); if ((str != null) && !(str.trim().equals("BYE"))) { out.println(str); str = is.readLine(); System.out.println(str); } else more = false; } // while } // main }