import java.io.*; import java.net.*; public class TextToEcho { public static void main(String argv[]) throws IOException, UnknownHostException { Socket conn = new Socket(argv[0], 7); PrintWriter talk = new PrintWriter(new OutputStreamWriter(conn.getOutputStream())); Reader listen = new InputStreamReader(conn.getInputStream()); talk.print(argv[1]); talk.flush(); /* we make sure that the chars reach the server */ char buffer[] = new char[80]; int n= listen.read(buffer, 0, 80); System.out.println("The server said: " + new String(buffer, 0, n)); talk.close(); listen.close(); conn.close(); } }