Closes all TCP connections and then the socket servers
979539
def cleanup_tcpsockets(self):
        
        for fileno in self._tcp_client_sockets.keys():
            self.close_tcp_client(fileno)
        for fileno, items in self._tcp_server_sockets.items():
            socket, cb = items
            debug("- _cleanup server socket connection (fd %s)" % fileno)
            self._epoll.unregister(fileno)
            socket.close()
        self._tcp_server_sockets = {}
702743
function close() {
  log.notice('removing the unix socket file')
  try {
    fs.unlinkSync(file);
  }catch(e){} // nothing to do at this point

  Server.prototype.close.call(this);
}
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
1233410
protected function disconnect()
    {
        $this->log('closing sockets ... ', Net_Notifier_Logger::VERBOSITY_ALL);

        foreach ($this->clients as $client) {
            $client->startClose(
                Net_Notifier_WebSocket_Connection::CLOSE_GOING_AWAY,
                'Server shutting down.'
            );
        }

        $this->clients = array();
        $this->socket  = null;

        $this->log('done' . PHP_EOL, Net_Notifier_Logger::VERBOSITY_ALL, false);

        $this->connected = false;
    }
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!")
1284608
def terminate(self):
    """"""
    # Tear down the Pailgun TCPServer.
    if self.pailgun:
      self.pailgun.server_close()

    super(PailgunService, self).terminate()
694157
@Override
    public void close() {
        // Use monitor to avoid race between external close and handler thread run()
        synchronized (closeMonitor) {
            // Close and clear streams, sockets etc.
            if (socket != null) {
                try {
                    // Terminates thread blocking on socket read
                    // and automatically closed depending streams
                    socket.close();
                } catch (IOException e) {
                    log.warn("Can not close socket", e);
                } finally {
                    socket = null;
                }
            }

            // Clear user data
            session = null;
            response = null;
        }
    }
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();
        }
    }
280821
private synchronized void closeAllAcceptedSockets() {
    for (int x = 0; x < socketList.size(); x++) {
      try {
        ((Socket) socketList.get(x)).close();
      } catch (Exception e) {
        // ignore for now
      }
    }

    // clear member variables
    socketMap.clear();
    socketList.clear();
  }
1075347
public void stopServer()
    {
        Log(Level.INFO, "Attempting to stop SocketServer");
        keepRunning = false;
        // Thread will be blocked waiting for input - unblock it by closing the socket underneath it:
        if (this.serverSocket != null)
        {
            try
            {
                this.serverSocket.close();
            }
            catch (IOException e)
            {
                Log(Level.WARNING, "Something happened when closing SocketServer: " + e);
            }
            this.serverSocket = null;
        }
    }
239807
protected void closeServerSocket() {
    ServerSocket serverSocket = getServerSocket();

    if (!close(serverSocket)) {
      getLogger().warning(() -> String.format(
        "Failed to close ServerSocket bound to address [%s], listening on port [%d]",
          serverSocket.getInetAddress(), serverSocket.getLocalPort()));
    }
  }
45293
public void stop() {
        try {
            safeClose(myServerSocket);
            closeAllConnections();
            myThread.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
54983
public void close() throws IOException {
    getLogger().debug("closing socket");
    this.closed = true;
    socket.close();
    fireSocketClosedEvent(null);
  }
684520
@Override
    public void shutdown() {
        synchronized (connections) {
            parent.channelCloses(this);
            for (final MessageInbound connection : connections) {
                try {
                    connection.getWsOutbound().close(0, null);
                } catch (final IOException e) {
                    LOG.error("Connection [" + connection.toString() + "] can't be closed.", e);
                } finally {
                    final ExecutorService executorService = connectionThreads.get(connection);
                    if (executorService != null) {
                        executorService.shutdown();
                    }
                    connectionThreads.remove(connection);
                }
            }
            connections.clear();
        }
        callback = null;
    }
1031828
def close(self):
        """"""
        try:
            self._socket.sendall('quit\r\n')
        except socket.error:
            pass
        try:
            self._socket.close()
        except socket.error:
            pass
1330918
public static void closeAll() {
    try { H2O._udpSocket.close(); } catch( IOException e ) { }
    try { H2O._apiSocket.close(); } catch( IOException e ) { }
    try { TCPReceiverThread.SOCK.close(); } catch( IOException e ) { }
  }
656658
public void close () {
		Connection[] connections = this.connections;
		if (INFO && connections.length > 0) info("kryonet", "Closing server connections...");
		for (int i = 0, n = connections.length; i < n; i++)
			connections[i].close();
		connections = new Connection[0];

		ServerSocketChannel serverChannel = this.serverChannel;
		if (serverChannel != null) {
			try {
				serverChannel.close();
				if (INFO) info("kryonet", "Server closed.");
			} catch (IOException ex) {
				if (DEBUG) debug("kryonet", "Unable to close server.", ex);
			}
			this.serverChannel = null;
		}

		UdpConnection udp = this.udp;
		if (udp != null) {
			udp.close();
			this.udp = null;
		}

		synchronized (updateLock) { // Blocks to avoid a select while the selector is used to bind the server connection.
		}
		// Select one last time to complete closing the socket.
		selector.wakeup();
		try {
			selector.selectNow();
		} catch (IOException ignored) {
		}
	}