import java.util.Date; import java.io.*; import java.net.*; /** * Tiny socket server for the Unix 'daytime' protocol. */ public class Dayserver { public static void main(String[] args) { ServerSocket theserver; Socket asocket; PrintWriter p; BufferedReader timestream; Socket csocket; try { theserver = new ServerSocket(13); try { while(true) { System.out.println("Waiting for customers..."); asocket = theserver.accept(); p = new PrintWriter(asocket.getOutputStream()); p.println(new Date()); p.close(); asocket.close(); // csocket.close(); // timestream.close(); } } catch(IOException e) { theserver.close(); System.err.println(e);} } catch(IOException e) { System.err.println(e);} } }