import java.net.*;
import java.io.*;public class Attack 
{
public static void main(String[] args) 
{
String host="localhost";
int port=21;
if(args.length>0) {
host=args[0];
          //  port=(new Integer(args[1])).intValue();
  port=Integer.parseInt(args[1]);
}
        
PrintWriter out=null;
BufferedReader networkIn=null;     try{
Socket theSocket=new Socket(host,port);
networkIn=new BufferedReader(new InputStreamReader(theSocket.getInputStream()));
BufferedReader userIn=new BufferedReader(new InputStreamReader(System.in));
out=new PrintWriter(theSocket.getOutputStream());
System.out.println("connected to echo serve");
        
 while (true)
 {
            String theLine=userIn.readLine();
if(theLine.equals(".")) break;
out.println(theLine);
out.flush();
            System.out.println(networkIn.readLine());
 }
}//END TRY catch(IOException e) {
            System.err.println(e);
}
finally {
            try
            {
             if(networkIn!=null) networkIn.close();
if(out!=null) out.close();
            }
            catch (IOException e) 
            {
            } }//END FINAL
     }//END MAIN
}//END CLASS