if(log.isDebugEnabled()) log.debug("multicast socket is closed, exception=" + sock_ex);
if(log.isTraceEnabled()) log.trace("multicast socket is closed, exception=" + sock_ex);
    public void run() {        DatagramPacket  packet;        byte            receive_buf[]=new byte[65535];        int             len;        byte[]          tmp, data;        InetAddress     sender_addr;        int             sender_port;        // moved out of loop to avoid excessive object creations (bela March 8 2001)        packet=new DatagramPacket(receive_buf, receive_buf.length);        while(mcast_receiver != null && mcast_recv_sock != null) {            try {                packet.setData(receive_buf, 0, receive_buf.length);                mcast_recv_sock.receive(packet);                sender_addr=packet.getAddress();                sender_port=packet.getPort();                len=packet.getLength();                data=packet.getData();                if(len == 1 && data[0] == 0) {                    if(log.isTraceEnabled()) log.trace("received dummy packet");                    continue;                }                if(len == 4) {  // received a diagnostics probe                    if(data[0] == 'd' && data[1] == 'i' && data[2] == 'a' && data[3] == 'g') {                        handleDiagnosticProbe(sender_addr, sender_port);                        continue;                    }                }                if(log.isTraceEnabled())                    log.trace("received (mcast) " + packet.getLength() + " bytes from " +                              sender_addr + ':' + sender_port + " (size=" + len + " bytes)");                if(len > receive_buf.length) {                    if(log.isErrorEnabled()) log.error("size of the received packet (" + len + ") is bigger than " +                                             "allocated buffer (" + receive_buf.length + "): will not be able to handle packet. " +                                             "Use the FRAG protocol and make its frag_size lower than " + receive_buf.length);                }                if(Version.compareTo(data) == false) {                    if(log.isWarnEnabled()) {                        StringBuffer sb=new StringBuffer();                        sb.append("packet from ").append(sender_addr).append(':').append(sender_port);                        sb.append(" has different version (").append(Version.printVersionId(data, Version.version_id.length));                        sb.append(") from ours (").append(Version.printVersionId(Version.version_id)).append("). ");                        if(discard_incompatible_packets)                            sb.append("Packet is discarded");                        else                            sb.append("This may cause problems");                        log.warn(sb.toString());                    }                    if(discard_incompatible_packets)                        continue;                }                if(use_incoming_packet_handler) {                    tmp=new byte[len];                    System.arraycopy(data, 0, tmp, 0, len);                    incoming_queue.add(new IncomingQueueEntry(mcast_addr, sender_addr, sender_port, tmp));                }                else                    handleIncomingUdpPacket(mcast_addr, sender_addr, sender_port, data);            }            catch(SocketException sock_ex) {                 if(log.isDebugEnabled()) log.debug("multicast socket is closed, exception=" + sock_ex);                break;            }            catch(InterruptedIOException io_ex) { // thread was interrupted                ; // go back to top of loop, where we will terminate loop            }            catch(Throwable ex) {                if(log.isErrorEnabled()) log.error("exception=" + ex + ", stack trace=" + Util.printStackTrace(ex));                Util.sleep(100); // so we don't get into 100% cpu spinning (should NEVER happen !)            }        }        if(log.isDebugEnabled()) log.debug("multicast thread terminated");    }