641 * the underlying protocol, such as a TCP error.
642 * @return The multicast {@code NetworkInterface} currently set. A placeholder
643 * NetworkInterface is returned when there is no interface set; it has
644 * a single InetAddress to represent any local address.
645 * @see #setNetworkInterface(NetworkInterface)
646 * @since 1.4
647 */
648 public NetworkInterface getNetworkInterface() throws SocketException {
649 NetworkInterface ni
650 = (NetworkInterface)getImpl().getOption(SocketOptions.IP_MULTICAST_IF2);
651 if (ni == null) {
652 InetAddress[] addrs = new InetAddress[1];
653 addrs[0] = InetAddress.anyLocalAddress();
654 return new NetworkInterface(addrs[0].getHostName(), 0, addrs);
655 } else {
656 return ni;
657 }
658 }
659
660 /**
661 * Disable/Enable local loopback of multicast datagrams
662 * The option is used by the platform's networking code as a hint
663 * for setting whether multicast data will be looped back to
664 * the local socket.
665 *
666 * <p>Because this option is a hint, applications that want to
667 * verify what loopback mode is set to should call
668 * {@link #getLoopbackMode()}
669 * @param disable {@code true} to disable the LoopbackMode
670 * @throws SocketException if an error occurs while setting the value
671 * @since 1.4
672 * @deprecated Use {@link #setOption(SocketOption, Object)} with
673 * {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP}
674 * instead. The loopback mode is enabled by default,
675 * {@code MulticastSocket.setOption(StandardSocketOptions.IP_MULTICAST_LOOP, false)}
676 * disables it.
677 * @see #getLoopbackMode
678 */
679 @Deprecated(since="14")
680 public void setLoopbackMode(boolean disable) throws SocketException {
681 getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP, Boolean.valueOf(disable));
|
641 * the underlying protocol, such as a TCP error.
642 * @return The multicast {@code NetworkInterface} currently set. A placeholder
643 * NetworkInterface is returned when there is no interface set; it has
644 * a single InetAddress to represent any local address.
645 * @see #setNetworkInterface(NetworkInterface)
646 * @since 1.4
647 */
648 public NetworkInterface getNetworkInterface() throws SocketException {
649 NetworkInterface ni
650 = (NetworkInterface)getImpl().getOption(SocketOptions.IP_MULTICAST_IF2);
651 if (ni == null) {
652 InetAddress[] addrs = new InetAddress[1];
653 addrs[0] = InetAddress.anyLocalAddress();
654 return new NetworkInterface(addrs[0].getHostName(), 0, addrs);
655 } else {
656 return ni;
657 }
658 }
659
660 /**
661 * Disable/Enable local loopback of multicast datagrams.
662 * The option is used by the platform's networking code as a hint
663 * for setting whether multicast data will be looped back to
664 * the local socket.
665 *
666 * <p>Because this option is a hint, applications that want to
667 * verify what loopback mode is set to should call
668 * {@link #getLoopbackMode()}
669 * @param disable {@code true} to disable the LoopbackMode
670 * @throws SocketException if an error occurs while setting the value
671 * @since 1.4
672 * @deprecated Use {@link #setOption(SocketOption, Object)} with
673 * {@link java.net.StandardSocketOptions#IP_MULTICAST_LOOP}
674 * instead. The loopback mode is enabled by default,
675 * {@code MulticastSocket.setOption(StandardSocketOptions.IP_MULTICAST_LOOP, false)}
676 * disables it.
677 * @see #getLoopbackMode
678 */
679 @Deprecated(since="14")
680 public void setLoopbackMode(boolean disable) throws SocketException {
681 getImpl().setOption(SocketOptions.IP_MULTICAST_LOOP, Boolean.valueOf(disable));
|