JDK-4377103 : MulticastSocket works incorrectly on Solaris 2.8 with localhost interface
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.4.0,1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,solaris_8
  • CPU: generic,x86,sparc
  • Submitted: 2000-10-06
  • Updated: 2012-10-09
  • Resolved: 2001-07-12
Related Reports
Relates :  
Description

Name: dfR10049			Date: 10/06/2000



MulticastSocket works wrong on Solaris 2.8 if "localhost" interface set.
MulticastSocket allows set interface to "localhost", join to 
desired group, send packet, but it cannot receive sent packet.

This bug is reproduced only on Solaris 2.8.

This is the test demonstrated the bug:

-------------------------------------
import java.net.*;

public class Test {
   public static void main(String args[]) {
        boolean passed = true;
        try {
            InetAddress in1 = InetAddress.getByName("localhost");
            InetAddress m_addr = InetAddress.getByName("224.80.80.80");
            MulticastSocket soc = new MulticastSocket(0);;

            soc.setInterface(in1);
            System.out.println("interface:      " + in1);

            soc.joinGroup(m_addr);
            System.out.println("joined to:      " + m_addr);

            byte[] data = {100, 101};
            int port = soc.getLocalPort();
            DatagramPacket pac = 
                    new DatagramPacket(data, data.length, m_addr, port);
            soc.setSoTimeout(10000);
            soc.send(pac);
            System.out.println("sent to:        " + m_addr);

            soc.receive(pac); 
            soc.leaveGroup(m_addr);
            InetAddress from = pac.getAddress();
            System.out.println("received from:  " + from);
            if (!in1.equals(from)) { 
                passed = false;
            }

            soc.close();
        } catch (Exception e) {
            passed = false;
            e.printStackTrace(System.out);
        }

        if (passed)
            System.out.println("test passed");
        else
            System.out.println("test failed");

    }
}
  

-------- output from the text on Solaris 2.7 ----------------
#> uname -a
SunOS falcon 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-5_10
#> java Test
interface:      localhost/127.0.0.1
joined to:      /224.80.80.80
sent to:        /224.80.80.80
received from:  /127.0.0.1
test passed

-------- output from the text on Solaris 2.8 ----------------
#> uname -a
SunOS stardust 5.8 s28_34 sun4u sparc SUNW,Ultra-1
#> java Test
interface:      localhost/127.0.0.1
joined to:      /224.80.80.80
sent to:        /224.80.80.80
java.io.InterruptedIOException: Receive timed out
        at java.net.PlainDatagramSocketImpl.receive(Native Method)
        at java.net.DatagramSocket.receive(DatagramSocket.java:392)
        at Test.main(Test.java:25)
test failed
----------------------------------------------

======================================================================

Comments
EVALUATION Solaris 2.8 has changed its handling of multicast via the loopback interface. Take the following scenario with a sender and receiver on the same host. If the receiver binds a datagram socket to INADDR_ANY and joins a multicast group with the interface set to INADDR_LOOPBACK. The sender sets the outgoing interface to INADDR_LOOPBACK. For Solaris < 2.8, the receiver gets packets sent by the sender. For Solaris 2.8, the receiver gets nothing. michael.mcmahon@ireland 2000-10-09 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Submitted Solaris ipv6 bug 4381708. Fix is dependent on this bug. michael.mcmahon@ireland 2000-10-23 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Bug is fixed now in Solaris 9. I'm going to close as a dup of that bug. michael.mcmahon@ireland 2001-07-12 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12-07-2001