class MulticastUtil {

    static MulticastSocket newMulticastSocket(InetAddress pAddress, String pMulticastGroup, int pMulticastPort, LogHandler pLogHandler) throws IOException {
        // TODO: IpV6 (not supported yet)
        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();

}