package multicastsample; import java.io.*; import java.net.*; /** * */ public class Main { private static final String MULTICAST_ADDRESS_IPV6 = "ff35:40:fdb4:353a:c83f:10::10"; private static final int MULTICAT_PORT_IPV6 = 10101; private static final int SEND_INTERVAL = 1000; /** * @param args the command line arguments * @exception Exception */ public static void main(String[] args) throws Exception { new Main().send(); } public void send() throws UnknownHostException, SocketException, IOException { InetAddress address = InetAddress.getByName(MULTICAST_ADDRESS_IPV6); int port = MULTICAT_PORT_IPV6; Sender sender = new Sender(); int i = 0; while(true) { String message = String.format("%04d %s", i + 1, "Odanagi Akinao"); println(String.valueOf(i + 1)); sender.send(address, port, message); wait(SEND_INTERVAL); i++; } } private void println(String text) { System.out.println(text); } private void wait(int milisec) { try { println("wait " + milisec + "mili sec."); Thread.sleep(milisec); } catch (InterruptedException ex) { } } }