code: private NetworkInterface assignNetworkInterfaceTo(
            final DatagramChannel channel,
            final String networkInterfaceName)
    throws IOException {
      
      if (networkInterfaceName != null && !networkInterfaceName.trim().isEmpty()) {
        final NetworkInterface specified = NetworkInterface.getByName(networkInterfaceName);
        if (specified != null) {
          channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, specified);
          return specified;
        }
      }
  
      // if networkInterfaceName not given or unknown, take best guess
      
      return assignBestGuessNetworkInterfaceTo(channel);
    }
docs: =========================================