Java tutorial
/* Chapter 3 - Simple Protocols Java 2 Network Protocols Black Book by Al Williams Paraglyph Press 2001 */ import java.net.*; import java.io.*; public class Time867 { public static void main(String[] args) { String hostname = "tock.usno.navy.mil"; if (args.length == 1) hostname = args[0]; try { int c; Socket sock = new Socket(hostname, 13); InputStream is = sock.getInputStream(); do { c = is.read(); if (c != -1) System.out.print((char) c); } while (c != -1); } catch (IOException e) { System.out.println(e); } } }