Index: impl/src/main/java/com/sun/enterprise/mgmt/transport/BlockingIOMulticastSender.java =================================================================== --- impl/src/main/java/com/sun/enterprise/mgmt/transport/BlockingIOMulticastSender.java (revision 1508) +++ impl/src/main/java/com/sun/enterprise/mgmt/transport/BlockingIOMulticastSender.java (working copy) @@ -105,22 +105,7 @@ Executor executor, int multicastTimeToLive, NetworkManager networkManager ) throws IOException { - if( host != null ) { - this.localSocketAddress = new InetSocketAddress( host, multicastPort ); - } else { - InetAddress firstInetAddress = null; - InetAddress multicastInetAddress = InetAddress.getByName( multicastAddress ); - // select appropriate IP version type - if( multicastInetAddress instanceof Inet6Address ) { - firstInetAddress = NetworkUtility.getFirstInetAddress( true ); - } else { - firstInetAddress = NetworkUtility.getFirstInetAddress( false ); - } - if( firstInetAddress != null ) - this.localSocketAddress = new InetSocketAddress( firstInetAddress, multicastPort ); - else - this.localSocketAddress = null; - } + this.localSocketAddress = host == null ? null : new InetSocketAddress( host, multicastPort ); this.multicastPort = multicastPort; if( multicastAddress == null ) multicastAddress = DEFAULT_MULTICAST_ADDRESS; @@ -128,11 +113,10 @@ this.multicastSocketAddress = new InetSocketAddress( multicastAddress, multicastPort ); if( networkInterfaceName != null ) { NetworkInterface anInterface = NetworkInterface.getByName( networkInterfaceName ); - if( NetworkUtility.supportsMulticast( anInterface ) ) + if( NetworkUtility.supportsMulticast( anInterface ) && anInterface.isUp() ) { this.anInterface = anInterface; + } } - if( this.anInterface == null ) - this.anInterface = NetworkUtility.getFirstNetworkInterface(); if( multicastPacketSize < DEFAULT_MULTICAST_PACKET_SIZE ) this.multicastPacketSize = DEFAULT_MULTICAST_PACKET_SIZE; else @@ -161,10 +145,15 @@ return; super.start(); multicastSocket = new MulticastSocket( multicastPort ); - if (anInterface != null) { - multicastSocket.setNetworkInterface(anInterface); - } else if (localSocketAddress != null) { - multicastSocket.setInterface(localSocketAddress.getAddress()); + if (anInterface != null && localSocketAddress != null) { + try { + multicastSocket.setInterface(localSocketAddress.getAddress()); + } catch (Exception e) { + LOG.log(Level.WARNING, "Unable to configure MulticastSocket to use specified interface with address: " + + localSocketAddress.getAddress() + + ". Continuning with default MulticastSocket interface of " + + multicastSocket.getInterface(), e); + } } //enable loopback. @@ -207,10 +196,7 @@ " network interface: " + multicastSocket.getNetworkInterface() + " multicast address:" + multicastAddress + " timeToLive=" + multicastSocket.getTimeToLive()); - if( anInterface != null ) - multicastSocket.joinGroup( multicastSocketAddress, anInterface ); - else - multicastSocket.joinGroup( multicastAddress ); + multicastSocket.joinGroup( multicastAddress ); } /** @@ -224,10 +210,7 @@ super.stop(); if( multicastSocket != null ) { try { - if( anInterface != null ) - multicastSocket.leaveGroup( multicastSocketAddress, anInterface ); - else - multicastSocket.leaveGroup( multicastAddress ); + multicastSocket.leaveGroup( multicastAddress ); } catch( IOException e ) { } multicastSocket.close();