package fixed;

import java.io.*;
import java.net.*;

public class Sender {

	public static void main(String argv[]) throws Exception {
		DatagramSocket socket = new DatagramSocket(6257);
		DatagramPacket packet;
		byte[] buf = new byte[2000];

		InetAddress receiverAddress = InetAddress.getByName(argv[0]);

		packet = new DatagramPacket(buf, buf.length, receiverAddress, 6257);
		int timeToSleep = (new Integer(argv[1])).intValue();

		long last = System.currentTimeMillis();
		long current = 0;

		int auxLastStatus = -1;
		while (true) {
			try {
				do {
					current = System.currentTimeMillis();
				} while ((last + timeToSleep) > current);
				socket.send(packet);
				last = current;
			} catch (IOException e) {
				e.printStackTrace();
			}
			//			socket.send(packet);
			//			Thread.sleep(timeToSleep);
		}
	}
}
