Close the connection down by immediately timing out any existing read
187776
public Boolean close() {
        _isClosing = true;
        boolean closeResult = true;
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
            Tr.debug(tc, "close, Initial read outstanding : " + _isInitialRead);
        }
        
        if(_isInitialRead){
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
                Tr.debug(tc, "close, Cancelling any outstanding read");
            }
            
            _tcpContext.getReadInterface().read(1, _tcpChannelCallback, false, TCPReadRequestContext.IMMED_TIMEOUT);
            
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "close, Call to cancel complete");
            }
            
            //This seems strange, but what happens during the timeout it will be set to false.
            //If it's false we don't want to do the wait since it's been called in line.
            //If it's true we will want to wait until the timeout has been processed
            if(_isInitialRead){
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "close, Timeout has been called, waiting for it to complete");
                }
                closeResult = true;
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
                    Tr.debug(tc, "close, No read outstanding, no reason to call cancel");
                }
                closeResult = false;
            }
        } else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
                Tr.debug(tc, "close, No read outstanding, no reason to call cancel");
            }
            closeResult = false;
        }
        
        if(_rl != null){
            if(!this.isAlldataReadCalled()) {
                try {

                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
                        Tr.debug(tc, "close, We are now closed, calling the ReadListener onAllDataRead");
                    }
                    this.setAlldataReadCalled(true);
                    _rl.onAllDataRead();
                } catch (IOException ioe) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){
                        Tr.debug(tc, "close, Encountered an exception while calling onAllDAtaRead : " + ioe);
                    }
                }
            }
        }
        
        return closeResult;
    }
375344
def teardown_socket(s):
  """"""
  try:
    s.shutdown(socket.SHUT_WR)
  except socket.error:
    pass
  finally:
    s.close()
629251
def close(self):
        """"""
        try:
            try:
                self.connection.quit()
            except socket.sslerror:
                # This happens when calling quit() on a TLS connection
                # sometimes.
                self.connection.close()
            except Exception as e:
                logger.error(
                    "Error trying to close connection to server " "%s:%s: %s",
                    self.host,
                    self.port,
                    e,
                )
                if self.fail_silently:
                    return
                raise
        finally:
            self.connection = None
471999
def shutdown(self):
        """"""

        if self.verbose:
            print(self.socket.getsockname(), 'xx', self.peername)

        try:
            self.socket.shutdown(socket.SHUT_RDWR)
        except IOError as err:
            assert err.errno is _ENOTCONN, "unexpected IOError: %s" % err
            # remote peer has already closed the connection,
            # just ignore the exceeption
            pass
661854
def close(self):
        """"""
        logger.debug('closing dongle, {} active connections'.format(len(self.conn_handles)))
        if self.is_scanning():
            logger.debug('in scanning mode, calling end_scan')
            self.end_scan()
        self.reset()
        if self.api is not None:
            self.api.stop_daemon()
            self.api = None
368927
def timeout(self, timeout):
        """"""
        self._proxy_json._timeout = timeout
        self._proxy_http._timeout = timeout
1361050
def sync_close_connection(self):
        """"""
        loop = asyncio.get_event_loop()
        task = loop.create_task(self.close_connection())
        loop.run_until_complete(task)
1167773
public function shutdown()
    {
        // Prevent user abort allowing onShutdown event to run without interruptions.
        if (\function_exists('ignore_user_abort')) {
            @ignore_user_abort(true);
        }

        // Close the session allowing new requests to be handled.
        if (isset($this['session'])) {
            $this['session']->close();
        }

        if ($this['config']->get('system.debugger.shutdown.close_connection', true)) {
            // Flush the response and close the connection to allow time consuming tasks to be performed without leaving
            // the connection to the client open. This will make page loads to feel much faster.

            // FastCGI allows us to flush all response data to the client and finish the request.
            $success = \function_exists('fastcgi_finish_request') ? @fastcgi_finish_request() : false;

            if (!$success) {
                // Unfortunately without FastCGI there is no way to force close the connection.
                // We need to ask browser to close the connection for us.
                if ($this['config']->get('system.cache.gzip')) {
                    // Flush gzhandler buffer if gzip setting was enabled.
                    ob_end_flush();

                } else {
                    // Without gzip we have no other choice than to prevent server from compressing the output.
                    // This action turns off mod_deflate which would prevent us from closing the connection.
                    if ($this['config']->get('system.cache.allow_webserver_gzip')) {
                        header('Content-Encoding: identity');
                    } else {
                        header('Content-Encoding: none');
                    }

                }


                // Get length and close the connection.
                header('Content-Length: ' . ob_get_length());
                header('Connection: close');

                ob_end_flush();
                @ob_flush();
                flush();
            }
        }

        // Run any time consuming tasks.
        $this->fireEvent('onShutdown');
    }
501129
def close(self):
        
        try:
            # TODO: Find a way to speed up this shutdown.
            if self.ssl:
                self._device.shutdown()

            else:
                # Make sure that it closes immediately.
                self._device.shutdown(socket.SHUT_RDWR)

        except Exception:
            pass

        Device.close(self)
1096811
def disconnect(self):
    """"""
    if self.sock is not None:
      try:
        self.sock.close()
      except socket.error:
        pass
      finally:
        self.sock = None
1278901
def close(self):
        """"""
        if not self.is_running:
            return

        self._state = CLOSED
        self.logger.debug('closing connection(s)')

        while True:
            try:
                conn = self._connections.get(block=False)
            except Empty:
                break

            conn.close_stream()

        self.on_close.send(self)
1093703
def close(self):
        """"""
        # Instead of actually closing the connection,
        # unshare it and/or return it to the pool.
        if self._con:
            self._pool.unshare(self._shared_con)
            self._shared_con = self._con = None
816156
void closeSocketImpl() {
        this.currentServerURI = null;

        // Signal the reader and writer
        this.reader.stop();
        this.writer.stop();

        // Close the current socket and cancel anyone waiting for it
        this.dataPortFuture.cancel(true);

        try {
            if (this.dataPort != null) {
                this.dataPort.close();
            }
        } catch (IOException ex) {
            processException(ex);
        }

        cleanUpPongQueue();

        // We signaled now wait for them to stop
        try {
            this.reader.stop().get(10, TimeUnit.SECONDS);
        } catch (Exception ex) {
            processException(ex);
        }
        try {
            this.writer.stop().get(10, TimeUnit.SECONDS);
        } catch (Exception ex) {
            processException(ex);
        }
    }
1057839
def release(self, conn):
        
        self._in_use.remove(conn)
        if conn.reader.at_eof() or conn.reader.exception():
            self._do_close(conn)
        else:
            self._pool.put_nowait(conn)
180256
def stop(self):
        """"""
        self.reconnect = False
        self.logger.debug("Shutting down.")
        if self.transport:
            self.transport.close()
1370167
def close_connection(self, host):
        """"""
        for h in self._cm.get_all(host):
            self._cm.remove(h)
            h.close()
110185
def disconnect(self):
        """"""
        # TODO Close the APs. When this is attempted, we get an undocumented 0x1d error. Doesn't
        #      seem to be necessary, anyway.
        self._memory_interfaces = {}
        
        self._link.enter_idle()
        self._is_connected = False