// It is now hard to find an NNTP server that will talk to // a member of the public. An out-of-date list is at: // http://ntp.isc.org/bin/view/Servers/StratumTwoTimeServers // // Still, even a refusal to talk tells you that you are in a client/server protocol. // // I failed with 10 -12 servers on Dec 30 2004, then succeeded with rolex.usg.edu import java.io.*; import java.net.*; public class AskTime { public static void main(String a[]) throws Exception { if (a.length!=1) { System.out.println("usage: java AskTime "); System.exit(0); } String machine = a[0]; final int daytimeport = 13; Socket so = new Socket(machine, daytimeport); BufferedReader br = new BufferedReader( new InputStreamReader( so.getInputStream() ) ); String time = br.readLine(); System.out.printf("%s says it is %s %n", machine, time); } }