public void stop() { Thread tmp=thread; thread=null; if(diag_sock != null) socket_factory.close(diag_sock); if(tmp != null) { try { tmp.join(Global.THREAD_SHUTDOWN_WAIT_TIME); } catch(InterruptedException e){ Thread.currentThread().interrupt(); // set interrupt flag } } }
public void stop() { running=false; try { getSocketFactory().close(serverSocket); } catch(Exception ignored) { } } }
protected void closeUnicastSocket() { getSocketFactory().close(sock); }
public static synchronized short getNextMulticastPort(InetAddress bind_addr) throws Exception { short port = mcast_port; try { DatagramSocket sock = Util.createDatagramSocket(socket_factory, "jgroups.temp.resourcemgr.mcast_sock", bind_addr, port); port = (short) sock.getLocalPort(); socket_factory.close(sock); return port; } finally { mcast_port = (short) (port + 1); } }
/** * Send the cookie first, then the our port number. If the cookie * doesn't match the receiver's cookie, the receiver will reject the * connection and close it. */ protected void sendLocalAddress(Address local_addr) throws Exception { try { // write the cookie out.write(cookie, 0, cookie.length); // write the version out.writeShort(Version.version); out.writeShort(local_addr.serializedSize()); // address size local_addr.writeTo(out); out.flush(); // needed ? updateLastAccessed(); } catch(Exception ex) { server.socket_factory.close(this.sock); connected=false; throw ex; } }
public void stop() { if(log.isDebugEnabled()) log.debug("closing server socket " + srv_sock.getLocalSocketAddress()); if(acceptor != null && acceptor.isAlive()) { try { // this will terminate thread, peer will receive SocketException (socket close) getSocketFactory().close(srv_sock); } catch(Exception ex) { } } synchronized(connections) { connections.forEach(Connection::stop); connections.clear(); } acceptor=null; super.stop(); }
@Test public void closeSocket() throws IOException { Socket socket = mock(Socket.class); this.subject.close(socket); verify(socket).close(); }
@Test public void closeDatagramSocket() { DatagramSocket socket = mock(DatagramSocket.class); this.subject.close(socket); verify(socket).close(); }
@Test public void closeServerSocket() throws IOException { ServerSocket socket = mock(ServerSocket.class); this.subject.close(socket); verify(socket).close(); }
@Test public void closeMulticastSocket() { MulticastSocket socket = mock(MulticastSocket.class); this.subject.close(socket); verify(socket).close(); } }
void closeMulticastSocket() { if(mcast_sock != null) { try { if(mcast_addr != null) { mcast_sock.leaveGroup(mcast_addr.getIpAddress()); } getSocketFactory().close(mcast_sock); // this will cause the mcast receiver thread to break out of its loop mcast_sock=null; if(log.isDebugEnabled()) log.debug("multicast socket closed"); } catch(IOException ex) { } mcast_addr=null; } }
public void stop() { running=false; try { getSocketFactory().close(serverSocket); } catch(Exception ignored) { } } }
@Override public void close(Socket socket) throws IOException { if (socket != null) { this.manager.getUnnamedRegistry().unregisterSocket(socket); this.factory.close(socket); } }
@Override public void close(DatagramSocket socket) { if (socket != null) { this.manager.getUnnamedRegistry().unregisterSocket(socket); this.factory.close(socket); } }
@Override public void close(ServerSocket socket) throws IOException { if (socket != null) { this.manager.getUnnamedRegistry().unregisterSocket(socket); this.factory.close(socket); } }
@Override public void close(DatagramSocket socket) { if (socket != null) { this.manager.getUnnamedRegistry().unregisterSocket(socket); this.factory.close(socket); } }
@Override public void close(Socket socket) throws IOException { if (socket != null) { this.manager.getUnnamedRegistry().unregisterSocket(socket); this.factory.close(socket); } }
@Override public void close(ServerSocket socket) throws IOException { if (socket != null) { this.manager.getUnnamedRegistry().unregisterSocket(socket); this.factory.close(socket); } }
@Test public void closeServerSocket() throws IOException { ServerSocket socket = new ServerSocket(); this.subject.close(socket); verify(this.factory).close(socket); verify(this.manager.getUnnamedRegistry()).unregisterSocket(socket); }
@Test public void closeSocket() throws IOException { Socket socket = new Socket(); this.subject.close(socket); verify(this.factory).close(socket); verify(this.manager.getUnnamedRegistry()).unregisterSocket(socket); }