1  /*  File:  SocketTest.java
  2   *
  3   *  Adapted from an example by
  4   *  Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM)
  5   *
  6   */
  7  
  8  import java.io.*;
  9  import java.net.*;
 10  
 11  class SocketTest
 12  {  public static void main( String[] args )
 13     {  try
 14  
 15        {  // open a socket connection to host at port 13 - date daemon
 16           Socket t = new Socket( "osprey7.npac.syr.edu", 13 );
 17  
 18           BufferedReader br =
 19             new BufferedReader(
 20               new InputStreamReader( t.getInputStream() ) );
 21     
 22           boolean more = true;
 23           while ( more )
 24           {  String str = br.readLine();
 25              if ( str == null )
 26                 more = false;
 27              else
 28                 System.out.println( str );
 29           }
 30        } 
 31        catch( IOException e ) 
 32        { System.out.println( "Error" + e.getMessage() ); }
 33     }
 34  }