import java.io.*;
import java.net.*;
import java.util.*;

public class BroadcastServer {
    public static void main(String[] args) throws java.io.IOException {
        new BroadcastServerThread().start();
    }
}

class BroadcastServerThread extends Thread {
    static InetAddress group;
    static final short port = 4446;
    boolean more;
    
    private long FIVE_SECONDS = 1000;

    public BroadcastServerThread() throws IOException {
        super("BroadcastServerThread");
    }

    public void run() {
        DatagramSocket socket = null; 
        more = true;
        while (more) {
            try {
                byte[] buf = new byte[256];

                    // construct quote
                String dString = new Date().toString();
                buf = dString.getBytes();

		    // send it
                group = InetAddress.getByName("255.255.255.255");
                socket = new DatagramSocket();
                DatagramPacket packet = new DatagramPacket(buf, buf.length, group, port);
                socket.send(packet);
                System.out.print(".");

		    // sleep for a while
		try {
		    sleep((long)(FIVE_SECONDS));
		} catch (InterruptedException e) { }
            } catch (IOException e) {
                e.printStackTrace();
	            more = false;
            }
        }
	socket.close();
    }
}
