@@ -0,0 +1,2851 @@
+package com.orbekk.net;%0A%0Aimport java.io.IOException;%0Aimport java.net.DatagramPacket;%0Aimport java.net.DatagramSocket;%0Aimport java.net.InetAddress;%0Aimport java.net.InterfaceAddress;%0Aimport java.net.NetworkInterface;%0Aimport java.net.SocketException;%0Aimport java.util.Enumeration;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A%0Apublic class Broadcaster %7B%0A    private Logger logger = LoggerFactory.getLogger(getClass());%0A    %0A    public List%3CInetAddress%3E getBroadcastAddresses() %7B%0A        List%3CInetAddress%3E broadcastAddresses = new LinkedList%3CInetAddress%3E();%0A        %0A        Enumeration%3CNetworkInterface%3E interfaces;%0A        try %7B%0A            interfaces = NetworkInterface.getNetworkInterfaces();%0A        %7D catch (SocketException e) %7B%0A            logger.warn(%22Network problem?%22, e.fillInStackTrace());%0A            return broadcastAddresses;%0A        %7D%0A        while (interfaces.hasMoreElements()) %7B%0A            NetworkInterface iface = interfaces.nextElement();%0A            try %7B%0A                if (iface.isLoopback()) %7B%0A                    logger.debug(%22Ignoring looback device %22 + iface.getName());%0A                    continue;%0A                %7D%0A                for (InterfaceAddress address : iface.getInterfaceAddresses()) %7B%0A                    InetAddress broadcast = address.getBroadcast();%0A                    if (broadcast != null) %7B%0A                        broadcastAddresses.add(broadcast);%0A                    %7D%0A                %7D%0A            %7D catch (SocketException e) %7B%0A                logger.info(%22Ignoring interface %22 + iface.getName(), e.fillInStackTrace());%0A            %7D%0A        %7D%0A        return broadcastAddresses;%0A    %7D%0A%0A    public boolean sendBroadcast(int port, byte%5B%5D data) %7B%0A        boolean successful = false;%0A        for (InetAddress broadcastAddress : getBroadcastAddresses()) %7B%0A            try %7B%0A                DatagramSocket socket = new DatagramSocket();%0A                socket.setBroadcast(true);%0A                DatagramPacket packet = new DatagramPacket(data, data.length, broadcastAddress, port);%0A                socket.send(packet);%0A                successful = true;%0A            %7D catch (SocketException e) %7B%0A                logger.warn(%22Failed to send broadcast to %22 + broadcastAddress +%0A                        %22. %22, e.fillInStackTrace());%0A            %7D catch (IOException e) %7B%0A                logger.warn(%22Error when sending broadcast to %22 +%0A                        broadcastAddress + %22.%22, e.fillInStackTrace());%0A            %7D%0A        %7D%0A        return successful;%0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        int port = Integer.parseInt(args%5B0%5D);%0A        Broadcaster broadcaster = new Broadcaster();%0A        String message = %22Broadcast from Java broadcaster.%22;%0A        broadcaster.sendBroadcast(port, message.getBytes());%0A    %7D%0A%7D%0A

Add Broadcaster for non-Android Java.