ServerSocket sock;
Socket clientSock;
try {
sock = new ServerSocket(TIME_PORT);
while ((clientSock = sock.accept()) != null) {
System.out.println("Accept from " +
clientSock.getInetAddress());
ObjectOutputStream os = new ObjectOutputStream(
clientSock.getOutputStream());
// Construct and write the Object
os.writeObject(new Date());
os.close();
}
} catch (IOException e) {
System.err.println(e);
}