Java Code Examples for java.net.MulticastSocket#isClosed()

The following examples show how to use java.net.MulticastSocket#isClosed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmDNSImpl.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
/**
 * Send an outgoing multicast DNS message.
 *
 * @param out
 * @exception IOException
 */
public void send(DNSOutgoing out) throws IOException {
    if (!out.isEmpty()) {
        byte[] message = out.data();
        final DatagramPacket packet = new DatagramPacket(message, message.length, _group, DNSConstants.MDNS_PORT);

        if (logger.isLoggable(Level.FINEST)) {
            try {
                final DNSIncoming msg = new DNSIncoming(packet);
                if (logger.isLoggable(Level.FINEST)) {
                    logger.finest("send(" + this.getName() + ") JmDNS out:" + msg.print(true));
                }
            } catch (final IOException e) {
                logger.throwing(getClass().toString(), "send(" + this.getName() + ") - JmDNS can not parse what it sends!!!", e);
            }
        }
        final MulticastSocket ms = _socket;
        if (ms != null && !ms.isClosed()) {
            ms.send(packet);
        }
    }
}