class ConfigurableUDPSource {

    public static DatagramSocket createUDPSocket(int port, InetAddress address, String sourceName) {
        try {
            DatagramSocket socket = new DatagramSocket(port, address);
            List<String> sources = new ArrayList<>();
            sources.add(sourceName);
            udpSocketToSources.put(socket, sources);
            new Thread(new UDPListener(socket)).start();
            log.debug("Source '{}' succeeded in creating UDP socket on port '{}' and address '{}'"
                    , sourceName, port, address);
            return socket;
        }
        catch (Exception e) {
            log.debug("Source '{}' failed to create UDP socket on port '{}' and address '{}'. Will try to share with "
                    + "other sources.", sourceName, port, address);
            log.trace("Error for binding failure is ", e);
            return null;
        }
    }

}