/*
	(c) 1998 Burton Rosenberg. All rights reserved
*/

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

public class WebClient
{
	private static final String USAGE_MESSAGE = "Usage: java WebClient url" ;
	private static final String GET_COMMAND = "GET /" ;
	
	public static void main(String [] args)
	{
		if ( args.length==0 )
		{
			System.out.println(USAGE_MESSAGE) ;
			System.exit(0) ;
		}
		(new WebClient()).start(args) ;
	}
	
	private void start(String [] args)
	{
		try {
			Socket sock = new Socket(args[0], 80) ;
			BufferedReader sysin =
				new BufferedReader( new InputStreamReader
				( sock.getInputStream() )) ;
			PrintWriter sysout =
				new PrintWriter( sock.getOutputStream(), true ) ;
			
			sysout.println(GET_COMMAND) ;
			String line ;
			while ((line=sysin.readLine())!=null )
			{
				System.out.println(line) ;
			}
				
			sock.close() ;
		}
		catch ( UnknownHostException uhe )
		{
			System.out.println(
			"UnknownHostException: could not find " + args[0] ) ;
		}
		catch ( IOException ioe )
		{
			System.out.println(
			"IOException: could not connect to " + args[0] ) ;
		}
	
	}

}
