import java.net.*;
import java.io.*;
import java.util.Date;

public class DayTimeServer
{
    public final static int port = 6464;

    public static void main(String args[]) {
        ServerSocket theServer;
        Socket theConnection;
        PrintStream p;
        
        try {
            theServer = new ServerSocket(port);
            System.out.println("Time server started");
            try {
                while(true) {
                    theConnection = theServer.accept();
                    p = new PrintStream(theConnection.getOutputStream());
                    p.println(new Date());
//                    theConnection.close();
                }
            }
            catch(IOException e) {
                theServer.close();
                System.out.println(e);
            }
        }
        catch(IOException e) {
            System.out.println(e);
        }
    }
}


