Closes communication socket gracefully
321949
public void close() throws IOException {
    if (closed) {
      return;
    }
    closed = true;

    stopIn();
    stopOut();

    // socket streams and socket itself should be already closed with stopIn() and stopOut()
    // but because it is idempotent, let's be good citizens and close corresponding streams as well
    in.close();
    out.close();

    terminateExecutor(readExecutor, "read");
    terminateExecutor(orchestratorExecutor, "orchestrator");

    socket.close();
  }
120701
def close(self):
        
        log.debug("Closing socket connection for %s:%d" % (self.host, self.port))
        if self._sock:
            # Call shutdown to be a good TCP client
            # But expect an error if the socket has already been
            # closed by the server
            try:
                self._sock.shutdown(socket.SHUT_RDWR)
            except socket.error:
                pass

            # Closing the socket should always succeed
            self._sock.close()
            self._sock = None
        else:
            log.debug("No socket found to close!")
1169940
@Override
    public void close() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "close");
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "SocketChannel close starting, local: " + socket.getLocalSocketAddress() + " remote: " + socket.getRemoteSocketAddress());
        }
        // synchronize on this SocketIOChannel to prevent duplicate closes from
        // being processed
        synchronized (this) {
            if (closed) {
                processClose = false;
            }
            closed = true;
        }
        if (processClose) {
            try {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    Tr.event(tc, "AsyncSocketChannel close, local: " + socket.getLocalSocketAddress() + " remote: " + socket.getRemoteSocketAddress());
                if (asyncChannel != null) {
                    asyncChannel.close();
                }
            } catch (IOException ioe) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "IOException while closing channel " + ioe.getMessage());
                }
            } finally {
                super.close();
            }
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "close called on channel already closed, local: " + socket.getLocalSocketAddress() + " remote: " + socket.getRemoteSocketAddress());
            }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "close");
        }
    }
498261
private void stopOut() throws IOException {
    if (outClosed) {
      return;
    }
    outClosed = true;

    LOG.log(Level.FINE, "Shutting down socket for output");

    // close socket for output - that will initiate normal socket close procedure; in case of TCP
    // socket this is
    // a buffer flush and TCP termination
    socket.shutdownOutput();
  }
1370055
protected void close() {
        guard.close();

        if (fd != null) {
            datagramSocketClose();
            ResourceManager.afterUdpClose();
            fd = null;
        }
    }
1233190
def close(self):
        
        keys = set(self._conns.keys())
        for key in keys:
            self.stop_socket(key)

        self._conns = {}
1196671
@Override
  public void close() {

    LOG.log(Level.FINE, "Closing netty transport socket address: {0}", this.localAddress);

    final ChannelGroupFuture clientChannelGroupFuture = this.clientChannelGroup.close();
    final ChannelGroupFuture serverChannelGroupFuture = this.serverChannelGroup.close();
    final ChannelFuture acceptorFuture = this.acceptor.close();

    final ArrayList<Future> eventLoopGroupFutures = new ArrayList<>(3);
    eventLoopGroupFutures.add(this.clientWorkerGroup.shutdownGracefully());
    eventLoopGroupFutures.add(this.serverBossGroup.shutdownGracefully());
    eventLoopGroupFutures.add(this.serverWorkerGroup.shutdownGracefully());

    clientChannelGroupFuture.awaitUninterruptibly();
    serverChannelGroupFuture.awaitUninterruptibly();

    try {
      acceptorFuture.sync();
    } catch (final Exception ex) {
      LOG.log(Level.SEVERE, "Error closing the acceptor channel for " + this.localAddress, ex);
    }

    for (final Future eventLoopGroupFuture : eventLoopGroupFutures) {
      eventLoopGroupFuture.awaitUninterruptibly();
    }

    LOG.log(Level.FINE, "Closing netty transport socket address: {0} done", this.localAddress);
  }
797827
@Override
    public void close() throws IOException {
        dispose();

        if(socket != null) {
            socket.close();
            socket = null;
        }
    }
664855
protected synchronized void disconnect()
    {
        if (socket != null)
        {
            logger.info("Closing socket.");
            try
            {
                socket.close();
            }
            catch (IOException ex)
            {
                logger.warn("Unable to close socket: " + ex.getMessage());
            }
            socket = null;
        }
        protocolIdentifier.reset();
    }
447116
public static void closeQuietly(@Nullable final Socket... sockets) {
    if (sockets == null) return;

    for (Socket socket : sockets) {
      if (socket == null) return;

      try {
        socket.close();
      } catch (IOException ignored) {}
    }
  }
1259925
synchronized void closeSocket() {

        @Nullable SocketChannel clientChannel = this.clientChannel;

        if (clientChannel != null) {

            try {
                clientChannel.socket().shutdownInput();
            } catch (ClosedChannelException ignored) {

            } catch (IOException e) {
                Jvm.debug().on(getClass(), e);
            }

            try {
                clientChannel.socket().shutdownOutput();
            } catch (ClosedChannelException ignored) {

            } catch (IOException e) {
                Jvm.debug().on(getClass(), e);
            }

            Closeable.closeQuietly(clientChannel);

            this.clientChannel = null;

            if (LOG.isDebugEnabled())
                Jvm.debug().on(getClass(), "closing", new StackTrace("only added for logging - please ignore !"));

            @NotNull final TcpSocketConsumer tcpSocketConsumer = this.tcpSocketConsumer;

            tcpSocketConsumer.tid = 0;
            tcpSocketConsumer.omap.clear();

            onDisconnected();

        }
    }
380281
public void close() throws IOException {
		Throwable throwable = null;

		try {
			socket.close();
			sender.close();
			receiver.close();
		} catch (Throwable t) {
			throwable = t;
		}

		try {
			destroyProcess(process);
		} catch (Throwable t) {
			throwable = ExceptionUtils.firstOrSuppressed(t, throwable);
		}

		ShutdownHookUtil.removeShutdownHook(shutdownThread, getClass().getSimpleName(), LOG);

		ExceptionUtils.tryRethrowIOException(throwable);
	}
313125
public static void close(Socket socket) {
        if (socket == null) {
            return;
        }
        try {
            socket.close();
        } catch (IOException e) {
            Logger.getLogger(IOUtil.class).finest("closeResource failed", e);
        }
    }
1258892
def close(self, close_socket=False):
        
        self._bm.stop_socket(self._conn_key)
        if close_socket:
            self._bm.close()
        time.sleep(1)
        self._depth_cache = None
1147902
def close(self):
        """"""

        try:
            self.sock.shutdown(socket.SHUT_RDWR)
            self.sock.close()
        except socket.error:
            pass
259687
def close(self):
        
        if not self.__closed:
            self.__closed = True
            self.pool.return_socket(self.sock)
            self.sock, self.pool = None, None
1071290
def server_close(self):
        
        if self.remove_file:
            try:
                os.remove(self.remove_file)
            except:
                pass
        self.socket.close()