Get all local addresses on which a multicast can be send

@return list of all multi cast capable addresses
321225
public static List<InetAddress> getMulticastAddresses() throws SocketException {
        Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
        List<InetAddress> ret = new ArrayList<InetAddress>();
        while (nifs.hasMoreElements()) {
            NetworkInterface nif = nifs.nextElement();
            if (checkMethod(nif, supportsMulticast) && checkMethod(nif, isUp)) {
                Enumeration<InetAddress> addresses = nif.getInetAddresses();
                while (addresses.hasMoreElements()) {
                    InetAddress addr = addresses.nextElement();
                    // TODO: IpV6 support
                    if (!(addr instanceof Inet6Address)) {
                        ret.add(addr);
                    }
                }
            }
        }
        return ret;
    }
1017567
public Set<SIBUuid8> getAllGetLocalisations () {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getAllGetLocalisations");

    final Set<SIBUuid8> rc = _trmFacade.getAllGetLocalisations();

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getAllGetLocalisations", rc);
    return rc;
  }
703161
def addresses(self):
        
        addresses = []
        for i in self.all_interfaces:
            if isinstance(i, VlanInterface):
                for v in i.interfaces:
                    addresses.append((v.address, v.network_value, v.nicid))
            else:
                addresses.append((i.address, i.network_value, i.nicid))
        return addresses
1060508
public static InetAddress getLocalIP() {
        try {
            Collection<InterfaceAddress> ips = getAllIPAddresses();
            if (ips.size() > 0) {
                return (InetAddress) ips.iterator().next().getAddress();
            } else {
                return null;
            }
        } catch (Exception e) {
            return null;
        }
    }
405304
public static Set<InetAddress> resolveLocalAddresses() {
        Set<InetAddress> addrs = new HashSet<InetAddress>();
        Enumeration<NetworkInterface> ns = null;
        try {
            ns = NetworkInterface.getNetworkInterfaces();
        } catch (SocketException e) {
            // ignored...
        }
        while (ns != null && ns.hasMoreElements()) {
            NetworkInterface n = ns.nextElement();
            Enumeration<InetAddress> is = n.getInetAddresses();
            while (is.hasMoreElements()) {
                InetAddress i = is.nextElement();
                if (!i.isLoopbackAddress() && !i.isLinkLocalAddress() && !i.isMulticastAddress()
                        && !isSpecialIp(i.getHostAddress())) addrs.add(i);
            }
        }
        return addrs;
    }
370190
public List<InetAddress> nodes() {
        List<InetAddress> allNodes = new ArrayList<InetAddress>();
        BucketConfig config = bucketConfig.get();
        for (NodeInfo nodeInfo : config.nodes()) {
            try {
                allNodes.add(InetAddress.getByName(nodeInfo.hostname().address()));
            } catch (UnknownHostException e) {
                throw new IllegalStateException(e);
            }
        }
        return allNodes;
    }
639085
private static InetAddress[] getAllLocalInetAddresses(final Log log) 
    throws SocketException {

        final List addresses = new ArrayList();
        
        // get the network adapters
        final Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
        while (netInterfaces.hasMoreElements()) {
            final NetworkInterface ni = (NetworkInterface)netInterfaces.nextElement();
            if (log != null) {
                log.debug("Found interface: " + ni.getName());
            }
            
            // get the IPs for this network interface
            final Enumeration ips = ni.getInetAddresses();
            while (ips.hasMoreElements()) {
                final InetAddress ip = (InetAddress)ips.nextElement();
                if (log != null) {
                    log.debug("Found ip: " + ip.getHostName() + "/" 
                        + ip.getHostAddress() + " on interface: " + ni.getName());
                }

                // ignore the local loopback address: 127.0.0.1
                if (!ip.isLoopbackAddress()) {
                    if (log != null) {
                        log.debug("Let's add this IP: " + ip.getCanonicalHostName());
                    }
                    addresses.add(ip);
                }
            }
        }
        
        return (InetAddress[])addresses.toArray(new InetAddress[addresses.size()]);
    }
1065733
public static List<String> getRemoteAddresses(HttpServletRequest request) {
        List<String> addresses = new ArrayList<String>();
        addresses.add(request.getRemoteHost());
        if (!request.getRemoteAddr().equals(request.getRemoteHost())) {
            // Store both remote host and remote address 
            addresses.add(request.getRemoteAddr());
        }
        final String forwardedFor = request.getHeader("X-Forwarded-For");
        if (forwardedFor != null) {
            // Also store address this request was forwarded for.
            final String[] parts = forwardedFor.split(",");
            for (String part : parts) {
                addresses.add(part);
            }
        }
        final String httpVia = request.getHeader("Via");
        if (httpVia != null) {
            // Also store address this request was forwarded for.
            final String[] parts = httpVia.split(",");
            for (String part : parts) {
                addresses.add(part);
            }
        }
        return Collections.unmodifiableList(addresses);
    }
70336
public Collection<String> getLocalPlacements() {
        List<String> placements = Lists.newArrayList();
        for (String placementName : _placementFactory.getValidPlacements()) {
            Placement placement;
            try {
                placement = get(placementName);
            } catch (UnknownPlacementException e) {
                continue;  // Placement must live in another data center.
            }
            placements.add(placement.getName());
        }
        return placements;
    }
1350700
public Address[] getAddresses() {
    if (addresses != null)
      return addresses;

    if (hosts != null) {
      addresses = new Address[hosts.length];
      for (int i = 0; i < hosts.length; i++)
        addresses[i] = new Address(hosts[i], factory.getPort());
      return addresses;
    }

    Address address = factory == null ? new Address("localhost", -1) : new Address(
        factory.getHost(), factory.getPort());
    return new Address[] { address };
  }
453955
@Pure
	public static Collection<InetAddress> getPrimaryAdapterAddresses() {
		final Enumeration<NetworkInterface> interfaces;
		try {
			interfaces = NetworkInterface.getNetworkInterfaces();
		} catch (SocketException exception) {
			return Collections.emptyList();
		}
		if (interfaces != null) {
			NetworkInterface inter;
			while (interfaces.hasMoreElements()) {
				inter = interfaces.nextElement();
				try {
					final byte[] addr = inter.getHardwareAddress();
					if (addr != null) {
						final Collection<InetAddress> inetList = new ArrayList<>();
						final Enumeration<InetAddress> inets = inter.getInetAddresses();
						while (inets.hasMoreElements()) {
							inetList.add(inets.nextElement());
						}
						return inetList;
					}
				} catch (SocketException exception) {
					// Continue to the next loop.
				}
			}
		}
		return Collections.emptyList();
	}
293493
function getBroadcastAddresses() {
    // enumerate interfaces
    var net = os.networkInterfaces();
    var broadcastAddresses = Object.keys(net)
        // flatten the array structure
        .map(function (k) { return net[k]; })
        .reduce(function (prev, cur) { return prev.concat.apply(prev, cur); }, [])
        // only use external IPv4 ones
        .filter(function (add) { return !add.internal && add.family === "IPv4"; })
        // extract address and subnet as number array
        .map(function (k) { return ({
        address: k.address.split(".").map(function (num) { return +num; }),
        netmask: k.netmask.split(".").map(function (num) { return +num; }),
    }); })
        // broadcast is address OR (not netmask)
        .map(function (add) {
        return add.address.map(function (val, i) { return (val | ~add.netmask[i]) & 0xff; });
    })
        // ignore unconnected ones
        .filter(function (add) { return add[0] !== 169; })
        // turn the address into a string again
        .map(function (a) { return a[0] + "." + a[1] + "." + a[2] + "." + a[3]; });
    return broadcastAddresses;
}
1124541
static InetAddress[] getGlobalInterfaces() throws SocketException {
        List<InetAddress> list = new ArrayList<InetAddress> ();
        for (NetworkInterface intf : getInterfaces()) {
            if (intf.isUp()) {
                for (InetAddress address : Collections.list(intf.getInetAddresses())) {
                    if (address.isLoopbackAddress() == false &&
                            address.isSiteLocalAddress() == false &&
                            address.isLinkLocalAddress() == false) {
                        list.add(address);
                    }
                }
            }
        }
        return list.toArray(new InetAddress[list.size()]);
    }
1169158
def GetIPAddresses(self):
    """"""
    result = []
    filtered_ips = ["127.0.0.1", "::1", "fe80::1"]

    for interface in self.interfaces:
      for address in interface.addresses:
        if address.human_readable_address not in filtered_ips:
          result.append(Text(address.human_readable_address))
    return sorted(result)
65905
public java.util.List<String> getDnsIpAddresses() {
        if (dnsIpAddresses == null) {
            dnsIpAddresses = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return dnsIpAddresses;
    }
795041
public String[] getLocalForwardings() {
		String[] r = new String[socketlisteners.size()];
		int index = 0;

		for (Enumeration<String> e = socketlisteners.keys(); e
				.hasMoreElements();) {
			r[index++] = e.nextElement();

		}
		return r;
	}
1087755
private static AddressClient.ListAddressesPagedResponse listAddresses(AddressClient client) {
    System.out.println("Listing addresses:");
    ProjectRegionName regionName =
        ProjectRegionName.newBuilder().setRegion(REGION).setProject(PROJECT_NAME).build();
    ListAddressesHttpRequest listRequest =
        ListAddressesHttpRequest.newBuilder().setRegion(regionName.toString()).build();
    AddressClient.ListAddressesPagedResponse response = client.listAddresses(listRequest);
    for (Address address : response.iterateAll()) {
      System.out.println("\t - " + address.toString());
    }
    return response;
  }