java.net.MulticastSocket#close ( )源码实例Demo

下面列出了java.net.MulticastSocket#close ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netty-4.1.22   文件: OioDatagramChannel.java
/**
 * Create a new instance from the given {@link MulticastSocket}.
 *
 * @param socket    the {@link MulticastSocket} which is used by this instance
 */
public OioDatagramChannel(MulticastSocket socket) {
    super(null);

    boolean success = false;
    try {
        socket.setSoTimeout(SO_TIMEOUT);
        socket.setBroadcast(false);
        success = true;
    } catch (SocketException e) {
        throw new ChannelException(
                "Failed to configure the datagram socket timeout.", e);
    } finally {
        if (!success) {
            socket.close();
        }
    }

    this.socket = socket;
    config = new DefaultOioDatagramChannelConfig(this, socket);
}
 
源代码2 项目: netty4.0.27Learn   文件: OioDatagramChannel.java
/**
 * Create a new instance from the given {@link MulticastSocket}.
 *
 * @param socket    the {@link MulticastSocket} which is used by this instance
 */
public OioDatagramChannel(MulticastSocket socket) {
    super(null);

    boolean success = false;
    try {
        socket.setSoTimeout(SO_TIMEOUT);
        socket.setBroadcast(false);
        success = true;
    } catch (SocketException e) {
        throw new ChannelException(
                "Failed to configure the datagram socket timeout.", e);
    } finally {
        if (!success) {
            socket.close();
        }
    }

    this.socket = socket;
    config = new DefaultDatagramChannelConfig(this, socket);
}
 
源代码3 项目: localization_nifi   文件: MulticastUtils.java
public static void closeQuietly(final MulticastSocket socket) {

        if (socket == null) {
            return;
        }

        try {
            socket.close();
        } catch (final Exception ex) {
            logger.debug("Failed to close multicast socket due to: " + ex, ex);
        }

    }
 
源代码4 项目: gemfirexd-oss   文件: UDP.java
void closeMulticastSocket() {
    if(mcast_recv_sock != null) {
        try {
            if(mcast_addr != null) {
                mcast_recv_sock.leaveGroup(mcast_addr.getIpAddress());
            }
            mcast_recv_sock.close(); // this will cause the mcast receiver thread to break out of its loop
            //mcast_recv_sock=null;
            if(log.isDebugEnabled()) log.debug("multicast receive socket closed");
        }
        catch(IOException ex) {
        }
        mcast_addr=null;
    }

    if(mcast_send_sock != null) {
        mcast_send_sock.close();
        //mcast_send_sock=null;
        if(log.isDebugEnabled()) log.debug("multicast send socket closed");
    }
    if(mcast_send_sockets != null) {
        MulticastSocket s;
        for(int i=0; i < mcast_send_sockets.length; i++) {
            s=mcast_send_sockets[i];
            s.close();
            if(log.isDebugEnabled()) log.debug("multicast send socket " + s + " closed");
        }
        mcast_send_sockets=null;
    }
}
 
源代码5 项目: gemfirexd-oss   文件: UDP.java
/**
 * Closes the datagram socket, any multicast receive sockets,
 * and interrupts their threads.
 */
@Override // GemStoneAddition  
public void emergencyClose() {
  closeSocket();

  MulticastSocket ms = mcast_recv_sock;
  if (ms != null) {
    ms.close();
  }
  ms = mcast_send_sock;
  if (ms != null) {
    ms.close();
  }
  if (mcast_send_sockets != null) {
    for (int i = 0; i < mcast_send_sockets.length; i ++) {
      ms = mcast_send_sockets[i];
      if (ms != null) {
        ms.close();
      }
    }
  }
  
  Thread thr = mcast_receiver;
  if (thr != null) {
    thr.interrupt();
  }
  UcastReceiver ur = ucast_receiver;
  if (ur != null) {
    thr = ur.thread;
    if (thr != null) {
      thr.interrupt();
      }
  }
}
 
源代码6 项目: gemfirexd-oss   文件: TP.java
/**
 * Closes the diagnostic handler, if it is open
 */
public void emergencyClose() {
  DiagnosticsHandler ds = diag_handler;
  if (ds != null) {
    MulticastSocket ms = ds.diag_sock;
    if (ms != null) {
      ms.close();
    }
    Thread thr = ds.t;
    if (thr != null) {
      thr.interrupt();
    }
  }
}
 
源代码7 项目: cacheonix-core   文件: IOUtils.java
public static void closeHard(final MulticastSocket multicastSocket) {

      if (multicastSocket == null) {
         return;
      }
      try {
         multicastSocket.close();
      } catch (final Exception e) {
         ignoreExpectedException(e);
      }
   }
 
源代码8 项目: gemfirexd-oss   文件: UDP.java
void closeMulticastSocket() {
    if(mcast_recv_sock != null) {
        try {
            if(mcast_addr != null) {
                mcast_recv_sock.leaveGroup(mcast_addr.getIpAddress());
            }
            mcast_recv_sock.close(); // this will cause the mcast receiver thread to break out of its loop
            //mcast_recv_sock=null;
            if(log.isDebugEnabled()) log.debug("multicast receive socket closed");
        }
        catch(IOException ex) {
        }
        mcast_addr=null;
    }

    if(mcast_send_sock != null) {
        mcast_send_sock.close();
        //mcast_send_sock=null;
        if(log.isDebugEnabled()) log.debug("multicast send socket closed");
    }
    if(mcast_send_sockets != null) {
        MulticastSocket s;
        for(int i=0; i < mcast_send_sockets.length; i++) {
            s=mcast_send_sockets[i];
            s.close();
            if(log.isDebugEnabled()) log.debug("multicast send socket " + s + " closed");
        }
        mcast_send_sockets=null;
    }
}
 
源代码9 项目: gemfirexd-oss   文件: UDP.java
/**
 * Closes the datagram socket, any multicast receive sockets,
 * and interrupts their threads.
 */
@Override // GemStoneAddition  
public void emergencyClose() {
  closeSocket();

  MulticastSocket ms = mcast_recv_sock;
  if (ms != null) {
    ms.close();
  }
  ms = mcast_send_sock;
  if (ms != null) {
    ms.close();
  }
  if (mcast_send_sockets != null) {
    for (int i = 0; i < mcast_send_sockets.length; i ++) {
      ms = mcast_send_sockets[i];
      if (ms != null) {
        ms.close();
      }
    }
  }
  
  Thread thr = mcast_receiver;
  if (thr != null) {
    thr.interrupt();
  }
  UcastReceiver ur = ucast_receiver;
  if (ur != null) {
    thr = ur.thread;
    if (thr != null) {
      thr.interrupt();
      }
  }
}
 
源代码10 项目: gemfirexd-oss   文件: TP.java
/**
 * Closes the diagnostic handler, if it is open
 */
public void emergencyClose() {
  DiagnosticsHandler ds = diag_handler;
  if (ds != null) {
    MulticastSocket ms = ds.diag_sock;
    if (ms != null) {
      ms.close();
    }
    Thread thr = ds.t;
    if (thr != null) {
      thr.interrupt();
    }
  }
}
 
源代码11 项目: Bitcoin   文件: Multicast.java
public static void destoryReceiver(MulticastSocket s) throws UnknownHostException, IOException {
    if (s == null)
        return;

    // Leave the multicast group and close the socket
    s.leaveGroup(InetAddress.getByName(GROUP));
    s.close();
}
 
源代码12 项目: Bitcoin   文件: Multicast.java
public static void destroySender(MulticastSocket s) throws IOException {
    if (s == null)
        return;

    // When we have finished sending data close the socket
    s.close();
}
 
源代码13 项目: nifi   文件: MulticastUtils.java
public static void closeQuietly(final MulticastSocket socket) {

        if (socket == null) {
            return;
        }

        try {
            socket.close();
        } catch (final Exception ex) {
            logger.debug("Failed to close multicast socket due to: " + ex, ex);
        }

    }
 
源代码14 项目: openhab1-addons   文件: SsdpDiscovery.java
private static void sendNotify(String notifyMessage, InetAddress ia) throws Exception {
    MulticastSocket socket = new MulticastSocket(null);
    try {
        socket.bind(new InetSocketAddress(PORT));
        socket.setTimeToLive(4);
        byte[] data = notifyMessage.toString().getBytes();
        socket.send(new DatagramPacket(data, data.length, new InetSocketAddress(ia, PORT)));
    } catch (Exception e) {
        logger.error("sendNotify", e);
        throw e;
    } finally {
        socket.disconnect();
        socket.close();
    }
}
 
源代码15 项目: sailfish-core   文件: MulticastSocketConnector.java
private void close(MulticastSocket socket) throws Exception
{
    socket.close();
}
 
源代码16 项目: sailfish-core   文件: MulticastSocketProcessor.java
private void destroy(MulticastSocketSession session) throws Exception {
	MulticastSocket socket = session.getSocket();

	socket.close();
}