title: Multicast in java
body: <p>I am trying to write a simple multicast trial.</p>
  
  <p>I used a standard code (sender and reciever).</p>
  
  <p>I tried a few different standard pieces of code. it appears that the receiving code is stuck on receive (as if it's not receving anything).</p>
  
  <p>receive side:</p>
  
  <pre><code>        byte[] b = new byte[3];
      DatagramPacket dgram = new DatagramPacket(b, b.length);
      MulticastSocket socket =
        new MulticastSocket(4545); // must bind receive side
      socket.joinGroup(InetAddress.getByName("226.100.100.125"));
  
      while(true) {
        socket.receive(dgram); // blocks until a datagram is received
        System.err.println("Received " + dgram.getLength() +
          " bytes from " + dgram.getAddress());
        dgram.setLength(b.length); // must reset length field!
      }
  </code></pre>
  
  <p>sending side:</p>
  
  <pre><code>      DatagramSocket socket = new DatagramSocket();
  
    byte[] b = new byte[]{(byte)1,(byte)5,(byte)3};
    DatagramPacket dgram;
  
    dgram = new DatagramPacket(b, b.length,
      InetAddress.getByName("226.100.100.125"), 4545);
  
    System.err.println("Sending " + b.length + " bytes to " +
      dgram.getAddress() + ':' + dgram.getPort());
    while(true) {
      System.err.print(".");
      socket.send(dgram);
      Thread.sleep(1000);
    }
  </code></pre>
  
  <p><strong>What is wrong with my code?</strong>
  *<em>I tried alot of different IPs also</em>*</p>
  
  <p>thanks for the help.</p>