Close down the socket. Will trigger the onClose handler if the socket has not been previously closed.
507347
public synchronized void close() {
        switch (state) {
            case NONE:
                state = State.DISCONNECTED;
                return;
            case CONNECTING:
                // don't wait for an established connection, just close the tcp socket
                closeSocket();
                return;
            case CONNECTED:
                // This method also shuts down the writer
                // the socket will be closed once the ack for the close was received
                sendCloseHandshake(true);
                return;
            case DISCONNECTING:
                return; // no-op;
            case DISCONNECTED:
                return;  // No-op
        }
    }
54983
public void close() throws IOException {
    getLogger().debug("closing socket");
    this.closed = true;
    socket.close();
    fireSocketClosedEvent(null);
  }
138684
def _shutdown_listen_socket(self):
        
        self.debug("()")
        if self._listen_socket in self._listening:
            self._listening.remove(self._listen_socket)
        if self._listen_socket:
            self._listen_socket.close()
        self._listen_socket = None
17799
public void close()
        throws IOException
    {
        try{
            _completing=true;
            if (_connection instanceof Socket && !(_connection instanceof SSLSocket))
                ((Socket)_connection).shutdownOutput();
            _outputStream.close();
            _inputStream.close();
        }
        finally
        {
            if (_handlingThread!=null && Thread.currentThread()!=_handlingThread)
                _handlingThread.interrupt();
        }
    }
1225265
def close(self):
        
        self.socket.setsockopt(SOL_SOCKET, SO_LINGER,
                               struct.pack('ii', 1, 1))
        self.socket.close()
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);
	}
1234067
private void closeOutgoingSockets() throws ClientException {

        SocketOperator op = new SocketOperator() {
                public void operate(SocketBox sb) throws Exception {
                    if (((ManagedSocketBox) sb).isReusable()) {
                        Socket s = sb.getSocket();
                        if (s != null) {
                            // write the closing Eblock and close the socket
                            EBlockImageDCWriter.close(
                                  new DataOutputStream(s.getOutputStream()));
                        }
                    }
                }
       };

        try {
            socketPool.applyToAll(op);
        } catch (IOException e) {
            // ignore - sometimes server might close the socket
        } catch (Exception e) {
            ClientException ce =
                new ClientException(ClientException.SOCKET_OP_FAILED);
            ce.setRootCause(e);
            throw ce;
        }
    }
452469
def close_connection(self):
        
        if self.port:
            self.port.close()
            self.logger.debug("Close TCP port")
797827
@Override
    public void close() throws IOException {
        dispose();

        if(socket != null) {
            socket.close();
            socket = null;
        }
    }
581677
def close(self):
        
        if self._socket is not None and self._conn is not None:
            message_input = UnityMessage()
            message_input.header.status = 400
            self._communicator_send(message_input.SerializeToString())
        if self._socket is not None:
            self._socket.close()
            self._socket = None
        if self._socket is not None:
            self._conn.close()
            self._conn = None
1184606
@Handler
    @SuppressWarnings("PMD.DataflowAnomalyAnalysis")
    public void onClose(Close event) throws IOException, InterruptedException {
        for (Channel channel : event.channels()) {
            if (channel instanceof TcpChannelImpl
                && channels.contains(channel)) {
                ((TcpChannelImpl) channel).close();
            }
        }
    }
438580
public void disconnect() {

		if (!connected) {
			return;
		}

		try {
			socket.close();
		} catch (IOException e) {
			LOG.debug("I/O exception when closing socket", e);
		}

		this.connected = false;
	}
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
1198847
@Override
    public void close() {
        if (closed)
            return;
        closed = true;
        tcpSocketConsumer.prepareToShutdown();

        if (shouldSendCloseMessage)

            eventLoop.addHandler(new EventHandler() {
                @Override
                public boolean action() throws InvalidEventHandlerException {
                    try {
                        TcpChannelHub.this.sendCloseMessage();
                        tcpSocketConsumer.stop();
                        closed = true;

                        if (LOG.isDebugEnabled())
                            Jvm.debug().on(getClass(), "closing connection to " + socketAddressSupplier);

                        while (clientChannel != null) {

                            if (LOG.isDebugEnabled())
                                Jvm.debug().on(getClass(), "waiting for disconnect to " + socketAddressSupplier);
                        }
                    } catch (ConnectionDroppedException e) {
                        throw new InvalidEventHandlerException(e);
                    }

                    // we just want this to run once
                    throw new InvalidEventHandlerException();
                }

                @NotNull
                @Override
                public String toString() {
                    return TcpChannelHub.class.getSimpleName() + "..close()";
                }
            });
    }
375344
def teardown_socket(s):
  """"""
  try:
    s.shutdown(socket.SHUT_WR)
  except socket.error:
    pass
  finally:
    s.close()
133167
def close(self):
        '''
        
        '''
        if self._closing:
            return
        self._closing = True
        if hasattr(self.sock, 'close'):
            self.sock.close()
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();
  }