
// SpaceWarServerTest
// Burton Rosenberg

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

public class SpaceWarServerTest {

   static final int PORT_NUMBER = 2234 ;

   public static void main( String [] args ) {
     
       if ( args.length < 1 ) {
          System.out.println("Usage: SpaceWarServerTest hostname") ;
          System.exit(0) ;
       }

       String remoteHost = args[0] ;
       Socket client ;
       InputStream is ;
       OutputStream os ;
       PrintStream ps ;
       DataInputStream dis ;

       try { 

          client = new Socket( remoteHost, PORT_NUMBER ) ;
          is = client.getInputStream() ;
          os = client.getOutputStream() ;
          ps = new PrintStream(os) ;

          dis = new DataInputStream( System.in ) ;

          String lineOfInput ;
          while ( (lineOfInput = dis.readLine()) != null ) {
             ps.println(lineOfInput) ;
          }

          client.close() ;
       }
       catch ( UnknownHostException uhe ) { 
           System.out.println("Error: Can't find host " + remoteHost ) ;
       }
       catch ( IOException ioe ) {
           System.out.println("Error: "+ ioe.getMessage() ) ;
       }

   }

}
