org.distributeme.test.udpbroadcast.BroadcastToAllServers Maven / Gradle / Ivy
package org.distributeme.test.udpbroadcast;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
/**
* Utility to broadcast to all instances.
*
* @author lrosenberg
* @since 22.02.15 18:11
*/
public class BroadcastToAllServers {
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public static void main(String a[]) throws Exception{
System.out.println("Trying to broadcast");
DatagramPacket outgoing = new DatagramPacket(new String("register").getBytes(), "register".length());
DatagramSocket socket = new DatagramSocket();
socket.setBroadcast(true);
outgoing.setAddress(InetAddress.getByAddress(new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255}));
for (int i=9250; i<9400; i++) {
outgoing.setPort(i);
socket.send(outgoing);
}
System.out.println("Sent ...");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy