package mil.navy.nps.testing; /*---------------------------------------------------------------------- A test of multicast receiving in java. Swiped from http://www.cdt.luth.se/~peppar/java/multicast_example/ ------------------------------------------------------------------------*/ import mil.navy.nps.dis.*; import java.net.*; // standard networking, in all "official" JDK 1.1 distributions // import sun.net.*; // multicast is in the Sun packages for JDK 1.0 public class MulticastTest extends Object { public static void main(String args[]) throws java.net.SocketException, java.io.IOException { int port = 3111; String group = "224.2.244.141"; MulticastSocket socket; byte buf[] = new byte[1500]; DatagramPacket packet = new DatagramPacket(buf, buf.length); EntityStatePdu aPdu; int idx, packetReceivedCount; socket = new MulticastSocket(port); socket.joinGroup(InetAddress.getByName(group)); while (true) { socket.receive(packet); System.out.println("Received data from: " + packet.getAddress().toString() + ":" + packet.getPort() + " with length: " + packet.getLength()); } } } // end of class MulticastTest