Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4148757

java.net.MulticastSocket.setTTL does not allow ttl=0

XMLWordPrintable

    • 1.2.2
    • generic, sparc
    • generic, solaris_2.5



      Name: yyC67448 Date: 06/15/98




      The java.net.setTTL method does not allow ttl = 0.

      In fact zero ttl's are not incorrect, the multicast datagrams with zero ttl will
      not be transmitted on any subnet, but may be delivered locally if the sending host
      belongs to the destination group and if multicast loopback has not been disabled
      on the sending socket.

      The TTL thresholds enforce the following convention:

               ---------------------------------+-------------
               Scope | Initial TTL
               ---------------------------------+-------------
               restricted to the same host | 0
               restricted to the same subnet | 1
               restricted to the same site | 32
               restricted to the same region | 64
               restricted to the same continent | 128
               unrestricted | 255
               ---------------------------------+-------------

      So, it is incorrect to exclude zero TTL from legal arguments for setTTL.


      Here is the test demonstrating the bug:

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


      public class test
      {
        
        public static void main(String args[])
        {
          MulticastSocket soc = null;
          InetAddress sin = null;

          try {
            soc = new MulticastSocket();
            sin = InetAddress.getByName("224.80.80.80");
          } catch(Exception e)
          {
            System.out.println("Failed. Unexpected Exception : " + e);
            System.exit(-1);
          }
          
          try {
            soc.setTTL(0);
          } catch(IllegalArgumentException e)
          {
            System.out.println("Failed: Unexpected IllegalArgumentException");
          } catch(Exception e)
          {
            System.out.println("Failed. Unexpected exception.. " + e);
            System.exit(0);
          }
          
          System.out.println("Passed. OKAY");
          
        }

      }
       

      ---------------------- Output from the test -----------------
      Failed. Unexpected IllegalArgumentException
      -----------------------------------------------------------------
      ======================================================================

            jdn Jeffrey Nisewanger (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: