// This code  is execerpted from Silberschatz's OS concepts 6th edition
// and partially modified for  CSC345 class
import java.net.*;
import java.io.*;

class Server
{
    public static void main(String[] args) throws IOException {
	Socket client = null;
	PrintWriter pout = null;
	ServerSocket sock = null;
	
	try {
	    sock = new ServerSocket(5155);
	    // now listen for connections

	    while (true) {
		client = sock.accept();

		pout = new PrintWriter(client.getOutputStream(), true);

		pout.println(new java.util.Date().toString());

		pout.close();
		client.close();

	    }
	}
	catch (IOException ioe) {
	    System.err.println(ioe);
	}
	finally {
	    if (client != null)
		client.close();
	    if (sock != null)
		sock.close();
	}
    }
}

