Java Code Examples for java.net.MulticastSocket#close()
The following examples show how to use
java.net.MulticastSocket#close() .
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: OioDatagramChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
/** * 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); }
Example 2
Source File: OioDatagramChannel.java From netty4.0.27Learn with Apache License 2.0 | 6 votes |
/** * 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); }
Example 3
Source File: MulticastUtils.java From localization_nifi with Apache License 2.0 | 5 votes |
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); } }
Example 4
Source File: UDP.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
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; } }
Example 5
Source File: UDP.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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(); } } }
Example 6
Source File: TP.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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(); } } }
Example 7
Source File: IOUtils.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void closeHard(final MulticastSocket multicastSocket) { if (multicastSocket == null) { return; } try { multicastSocket.close(); } catch (final Exception e) { ignoreExpectedException(e); } }
Example 8
Source File: UDP.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
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; } }
Example 9
Source File: UDP.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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(); } } }
Example 10
Source File: TP.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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(); } } }
Example 11
Source File: Multicast.java From Bitcoin with Apache License 2.0 | 5 votes |
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(); }
Example 12
Source File: Multicast.java From Bitcoin with Apache License 2.0 | 5 votes |
public static void destroySender(MulticastSocket s) throws IOException { if (s == null) return; // When we have finished sending data close the socket s.close(); }
Example 13
Source File: MulticastUtils.java From nifi with Apache License 2.0 | 5 votes |
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); } }
Example 14
Source File: SsdpDiscovery.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
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(); } }
Example 15
Source File: MulticastSocketConnector.java From sailfish-core with Apache License 2.0 | 4 votes |
private void close(MulticastSocket socket) throws Exception { socket.close(); }
Example 16
Source File: MulticastSocketProcessor.java From sailfish-core with Apache License 2.0 | 4 votes |
private void destroy(MulticastSocketSession session) throws Exception { MulticastSocket socket = session.getSocket(); socket.close(); }