MulticastUtil { static MulticastSocket newMulticastSocket(InetAddress pAddress, String pMulticastGroup, int pMulticastPort, LogHandler pLogHandler) throws IOException { InetSocketAddress socketAddress = new InetSocketAddress(pMulticastGroup, pMulticastPort); MulticastSocket socket = new MulticastSocket(pMulticastPort); socket.setReuseAddress(true); setOutgoingInterfaceForMulticastRequest(pAddress, socket); socket.setTimeToLive(255); if (joinMcGroupsOnAllNetworkInterfaces(socket, socketAddress, pLogHandler) == 0) { throw new IOException("Couldn't join multicast group " + socketAddress + " on any network interfaces"); } return socket; } private  MulticastUtil(); static List<DiscoveryIncomingMessage> sendQueryAndCollectAnswers(DiscoveryOutgoingMessage pOutMsg, int pTimeout, String pMulticastGroup, int pMulticastPort); static List<DiscoveryIncomingMessage> sendQueryAndCollectAnswers(DiscoveryOutgoingMessage pOutMsg,
                                                                            int pTimeout,
                                                                            String pMulticastGroup,
                                                                            int pMulticastPort,
                                                                            LogHandler pLogHandler);  }
@Test public void createSocketNoAddress() throws IOException { InetAddress address = Inet6Address.getByName("fe80::e2f8:47ff:fe42:d872"); String multicastGroup = ConfigKey.MULTICAST_GROUP.getDefaultValue(); int multicastPort = Integer.valueOf(ConfigKey.MULTICAST_PORT.getDefaultValue()); if (NetworkUtil.isMulticastSupported()) { MulticastUtil.newMulticastSocket(address, multicastGroup, multicastPort, new QuietLogHandler()); } else { try { MulticastUtil.newMulticastSocket(address, multicastGroup, multicastPort, new QuietLogHandler()); fail(); } catch (IOException exp) { } } }