/* File: SocketTest.java * * Adapted from an example by * Gary Cornell and Cay S. Horstmann, Core Java (Book/CD-ROM) * */ import java.io.*; import java.net.*; class SocketTest { public static void main( String[] args ) { try { // open a socket connection to host at port 13 - date daemon Socket t = new Socket( "osprey7.npac.syr.edu", 13 ); BufferedReader br = new BufferedReader( new InputStreamReader( t.getInputStream() ) ); boolean more = true; while ( more ) { String str = br.readLine(); if ( str == null ) more = false; else System.out.println( str ); } } catch( IOException e ) { System.out.println( "Error" + e.getMessage() ); } } }