FileDocCategorySizeDatePackage
DaytimeText.javaAPI DocExample733Mon Mar 13 12:17:00 GMT 2000None

DaytimeText

public class DaytimeText extends Object
DaytimeText - connect to the Daytime (ascii) service.
author
Ian F. Darwin
version
$Id: DaytimeText.java,v 1.3 2000/03/13 17:17:01 ian Exp $

Fields Summary
public static final short
TIME_PORT
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)


	     
		String hostName;
		if (argv.length == 0)
			hostName = "localhost";
		else
			hostName = argv[0];

		try {
			Socket sock = new Socket(hostName, TIME_PORT);
			BufferedReader is = new BufferedReader(new 
				InputStreamReader(sock.getInputStream()));
			String remoteTime = is.readLine();
			System.out.println("Time on " + hostName + " is " + remoteTime);
		} catch (IOException e) {
			System.err.println(e);
		}