/** 
 * This program is an example from the book "Internet 
 * programming with Java" by Svetlin Nakov. It is freeware. 
 * For more information: http://www.nakov.com/books/inetjava/ 
 */ 
import java.io.*; 
import java.net.Socket; 
 
public class DateServerClient { 
    public static void main(String[] args) throws IOException { 
        Socket socket = new Socket("localhost", 2002); 
        BufferedReader in = new BufferedReader( 
            new InputStreamReader( 
                socket.getInputStream() ) ); 
        System.out.println("The date on the server is: " + 
            in.readLine()); 
        socket.close(); 
    } 
}
Back to Internet Programming with Java books's web site