protected void broadcastMessage(final byte[] msg) throws SocketException, IOException {
        final int messageLength = msg.length;
        final DatagramPacket sendPacket = new DatagramPacket(msg, messageLength, InetAddress.getByName("255.255.255.255"), GlobalConstants.DEFAULT_PORT);

        if (broadcast) {
            // Find the clients using UDP broadcast                
            // Try the 255.255.255.255 first            
            ds.send(sendPacket);

            // Broadcast the message over all the network interfaces
            final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
            NetworkInterface networkInterface;
            InetAddress broadcastIp;
            while (interfaces.hasMoreElements()) {
                networkInterface = interfaces.nextElement();

                if (!networkInterface.isUp()) {
                    continue;
                }

                for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses()) {
                    broadcastIp = interfaceAddress.getBroadcast();
                    if (broadcastIp == null) {
                        continue;
                    }

                    // Send the broadcast                    
                    ds.send(new DatagramPacket(msg, messageLength, broadcastIp, GlobalConstants.DEFAULT_PORT));
                }
            }
            broadcast = false;
        } else {
            ms.send(sendPacket);
            broadcast = true;
        }
    }