< prev index next >

src/java.base/share/classes/java/net/MulticastSocket.java

Print this page
M MulticastSocket.java


 792                         }
 793                     }
 794                     byte dttl = getTTL();
 795                     try {
 796                         if (ttl != dttl) {
 797                             // set the ttl
 798                             getImpl().setTTL(ttl);
 799                         }
 800                         // call the datagram method to send
 801                         getImpl().send(p);
 802                     } finally {
 803                         // set it back to default
 804                         if (ttl != dttl) {
 805                             getImpl().setTTL(dttl);
 806                         }
 807                     }
 808                 } // synch p
 809             }  //synch ttl
 810     } //method
 811 
 812     private static Set<SocketOption<?>> options;
 813     private static boolean optionsSet = false;
 814 
 815     @Override
 816     public Set<SocketOption<?>> supportedOptions() {
 817         synchronized (MulticastSocket.class) {
 818             if (optionsSet) {
 819                 return options;
 820             }





 821             try {
 822                 DatagramSocketImpl impl = getImpl();
 823                 options = Collections.unmodifiableSet(impl.supportedOptions());
 824             } catch (SocketException ex) {
 825                 options = Collections.emptySet();
 826             }
 827             optionsSet = true;
 828             return options;
 829         }
 830     }
 831 }


 792                         }
 793                     }
 794                     byte dttl = getTTL();
 795                     try {
 796                         if (ttl != dttl) {
 797                             // set the ttl
 798                             getImpl().setTTL(ttl);
 799                         }
 800                         // call the datagram method to send
 801                         getImpl().send(p);
 802                     } finally {
 803                         // set it back to default
 804                         if (ttl != dttl) {
 805                             getImpl().setTTL(dttl);
 806                         }
 807                     }
 808                 } // synch p
 809             }  //synch ttl
 810     } //method
 811 
 812     private volatile Set<SocketOption<?>> options;
 813     private final Object optionsLock = new Object();
 814 
 815     @Override
 816     public Set<SocketOption<?>> supportedOptions() {
 817         Set<SocketOption<?>> options = this.options;
 818          if (options != null)
 819              return options;
 820 
 821          synchronized (optionsLock) {
 822             options = this.options;
 823             if (options != null)
 824                 return options;
 825 
 826             try {
 827                 DatagramSocketImpl impl = getImpl();
 828                 options = Collections.unmodifiableSet(impl.supportedOptions());
 829             } catch (IOException e) {
 830                 options = Collections.emptySet();
 831             }
 832             return this.options = options;

 833         }
 834     }
 835 }
< prev index next >