Java Utililty Methods Broadcast Address Get

List of utility methods to do Broadcast Address Get

Description

The list of methods to do Broadcast Address Get are organized into topic(s).

Method

InetAddressgetBroadcastAddress()
Find broadcast address for multicast gossip implementations
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
    NetworkInterface networkInterface = interfaces.nextElement();
    if (networkInterface.isLoopback() || !networkInterface.supportsMulticast()) {
        continue;
    for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) {
        InetAddress broadcast = interfaceAddress.getBroadcast();
...
SetgetBroadcastAddresses()
FROM edu.nps.moves.examples.EspduSender A number of sites get all snippy about using 255.255.255.255 for a bcast address; it trips their security software and they kick you off their network.
Set<InetAddress> bcastAddresses = new HashSet<InetAddress>();
Enumeration<NetworkInterface> interfaces;
try {
    interfaces = NetworkInterface.getNetworkInterfaces();
    while (interfaces.hasMoreElements()) {
        NetworkInterface anInterface = (NetworkInterface) interfaces.nextElement();
        if (anInterface.isUp()) {
            Iterator<InterfaceAddress> it = anInterface.getInterfaceAddresses().iterator();
...
ListgetBroadcastAddresses()
Retrives all the broadcast address of the machine (depending of the different network interfaces)
List<InetAddress> addresses = new ArrayList<>();
Enumeration<NetworkInterface> interfaces;
try {
    interfaces = NetworkInterface.getNetworkInterfaces();
} catch (SocketException ex) {
    return addresses;
for (NetworkInterface networkInterface = interfaces.nextElement(); interfaces
...
ListgetBroadcastAddresses()
get Broadcast Addresses
return getBroadcastAddresses(true);
InetSocketAddress[]getBroadcastAddresses(int port)
Get broadcast addresses.
Enumeration nets;
try {
    nets = NetworkInterface.getNetworkInterfaces();
} catch (SocketException se) {
    return new InetSocketAddress[] { new InetSocketAddress("255.255.255.255", port) };
ArrayList list = new ArrayList(10);
while (nets.hasMoreElements()) {
...
InetSocketAddress[]getBroadcastAddresses(int port)
Get broadcast addresses.
Enumeration<NetworkInterface> nets;
try {
    nets = NetworkInterface.getNetworkInterfaces();
} catch (SocketException se) {
    return new InetSocketAddress[] { new InetSocketAddress("255.255.255.255", port) };
ArrayList<InetSocketAddress> list = new ArrayList<InetSocketAddress>(10);
while (nets.hasMoreElements()) {
...