DateClient import java.net.*; import java.io.*; public class DateClient { static final int LISTENING_PORT = 32007; public static void main(String[] args) { String computer; // Name of the computer to connect to. Socket connection; // A socket for communicating with // that computer. Reader incoming; // Stream for reading data from // the connection. /* Get computer name from command line. */ if (args.length > 0) computer = args[0]; else { // No computer name was given. Print a message and exit. System.out.println("Usage: java DateClient "); return; } /* Make the connection, then read and display a line of text. */ try { connection = new Socket( computer, LISTENING_PORT ); incoming = new InputStreamReader( connection.getInputStream() ); while (true) { int ch = incoming.read(); if (ch == -1 || ch == ' ' || ch == ' ') break; System.out.print( (char)ch ); } System.out.println(); incoming.close(); } catch (Exception e) { TextIO.putln("Error: " + e); } } // end main() } //end class DateClient