Close the websocket.
422656
@Override
  public void close(WebSocketClose reason, String text)
  {
    Objects.requireNonNull(reason);

    if (_state.isClosed()) {
      return;
    }

    _state = _state.closeSelf();

    _frameOut.close(reason, text);

    if (_state.isClosed()) {
      disconnect();
    }
  }
393742
@Override
	public void close() {
		try {
			callbackRegistry.acceptConnectionStateChange(BitfinexConnectionStateEnum.DISCONNECTION_INIT);
			logger.debug("close() called");
			if (heartbeatThread != null) {
				heartbeatThread.interrupt();
				heartbeatThread = null;
			}

			if (websocketEndpoint != null) {
				websocketEndpoint.close();
				websocketEndpoint = null;
			}
			connectionStateChange(BitfinexConnectionStateEnum.DISCONNECTION_SUCCESS);
		} catch (final Exception e) {
			connectionStateChange(BitfinexConnectionStateEnum.DISCONNECTION_FAILED);
			throw new BitfinexClientException(e);
		}
	}
1188491
def close(self):
        """"""
        self.cancel()
        self.backend.close()
        self._closed = True
549081
public void close()
    throws IOException
  {
    ServerSocket ss = _ss;
    _ss = ss;

    if (ss != null) {
      try {
        ss.close();
      } catch (Exception e) {
      }
    }
  }
282233
function close() {
        $this->_error_log('closing socket ' . $this->sock);
        $this->_connection_closed = true;
        fclose($this->sock);
    }
1371515
protected function close()
    {
        if ($this->socket !== false) {
            fclose($this->socket);
            $this->socket = false;
        }
    }
1155529
def disconnect(self):
        
        logger.debug("Disconnecting")

        # Close off the websocket
        if self.ws:
            try:
                if self._state == STATE_CONNECTED:
                    self.handle_leave()
                    self.send_message(GOODBYE(
                          details={},
                          reason="wamp.error.system_shutdown"
                        ))
                logger.debug("Closing Websocket")
                try:
                    self.ws.close()
                except Exception as ex:
                    logger.debug("Could not close websocket connection because: {}".format(ex))
            except Exception as ex:
                logger.debug("Could not send Goodbye message because {}".format(ex))
                pass # FIXME: Maybe do better handling here
            self.ws = None

        # Cleanup the state variables. By settings this
        # we're going to be telling the main loop to stop
        # trying to read from a websocket and await a notice
        # of restart via a threading.Condition object
        self._state = STATE_DISCONNECTED

        # Send a message to all queues that we have disconnected
        # Without this, any requests that are awaiting a response
        # will block until timeout needlessly
        for request_id, request_queue in self._requests_pending.items():
            request_queue.put(GOODBYE(
                          details={},
                          reason="wamp.error.system_shutdown"
                        ))
        self._requests_pending = {}
        self.handle_disconnect()
679624
def close(self):
        
        self.stopped.set()
        for event in self.to_be_stopped:
            event.set()
        if self._receiver_thread is not None:
            self._receiver_thread.join()
        self._socket.close()
134265
public void close()
  {
    SocketPool loadBalancePool = _loadBalanceSocketPool.get();
    
    if (loadBalancePool != null)
      loadBalancePool.getFactory().close();
    
    SocketPool clusterPool = _clusterSocketPool.get();
    
    if (clusterPool != null)
      clusterPool.getFactory().close();
  }
186526
private void close()
    {
        assert (fd != null);

        try {
            fd.close();
            socket.eventClosed(endpoint, fd);
        }
        catch (IOException e) {
            socket.eventCloseFailed(endpoint, ZError.exccode(e));
        }
        fd = null;
    }
834046
def close(self) -> None:
        """"""
        if not self._closed:
            self._async_client.close()
            self._io_loop.close()
            self._closed = True
85256
def shutdown(self):
        """"""
        if self.OPEN:
            self.OPEN = False
            scoop.SHUTDOWN_REQUESTED = True
            self.socket.send(b"SHUTDOWN")
            self.socket.close()
            self.infoSocket.close()
            time.sleep(0.3)
344764
public void close() {
        if (connected.compareAndSet(true, false)) {
            // remove handshake flag
            session.removeAttribute(Constants.HANDSHAKE_COMPLETE);
            // clear the delay queue
            queue.clear();
            // whether to attempt a nice close or a forceful one
            if (WebSocketTransport.isNiceClose()) {
                // send a proper ws close
                Packet packet = Packet.build(Constants.CLOSE_MESSAGE_BYTES, MessageType.CLOSE);
                WriteFuture writeFuture = session.write(packet);
                writeFuture.addListener(new IoFutureListener<WriteFuture>() {

                    @Override
                    public void operationComplete(WriteFuture future) {
                        if (future.isWritten()) {
                            log.debug("Close message written");
                            // only set on success for now to skip boolean check later
                            session.setAttribute(Constants.STATUS_CLOSE_WRITTEN, Boolean.TRUE);
                        }
                        future.removeListener(this);
                    }

                });
                // adjust close routine to allow for flushing
                CloseFuture closeFuture = session.closeOnFlush();
                closeFuture.addListener(new IoFutureListener<CloseFuture>() {

                    public void operationComplete(CloseFuture future) {
                        if (future.isClosed()) {
                            log.debug("Connection is closed");
                        } else {
                            log.debug("Connection is not yet closed");
                        }
                        future.removeListener(this);
                    }

                });
            } else {
                // force close
                CloseFuture closeFuture = session.closeNow();
                closeFuture.addListener(new IoFutureListener<CloseFuture>() {

                    public void operationComplete(CloseFuture future) {
                        if (future.isClosed()) {
                            log.debug("Connection is closed");
                        } else {
                            log.debug("Connection is not yet closed");
                        }
                        future.removeListener(this);
                    }

                });
            }
        }
    }
69866
def close(self):
        """"""
        uwsgi.disconnect()
        if self._req_ctx is None:
            # better kill it here in case wait() is not called again
            self._select_greenlet.kill()
            self._event.set()
605281
public void close() {
        done = true;
        connected = false;
        synchronized (this) {
            try {
                if (socket != null) {
                    if (traceLevel >= ctrlThreshold) {
                        System.out.println("-> CLOSE");
                    }
                    socket.close();
                }
            } catch (final IOException e) { /* ignore socket close errors */
            } finally {
                socket = null;
            }
        }
    }
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
341943
def stop(self):
        
        if self.socket is not None:
            self.socket.close()
            self.socket = None
            self.data = None