Reconnect connection

@param bool $close_current close current existed connection
@return bool
348143
public function reconnect($close_current = true)
    {
        Debug::Log(Debug::INFO, 'reconnect()');
        if ($close_current) {
            Debug::Log(Debug::DEBUG, 'reconnect(): close current');
            if($this->socket->isConnected()) {
                $this->disconnect();
            }
            $this->socket->close();
        }

        $this->connect();
    }
844761
def reconnect(self):
        
        if self._auth_method is "userpass":
            self._mgr = manager.connect(host=self._conn[0],
                                        port=self._conn[1],
                                        username=self._auth[0],
                                        password=self._auth[1],
                                        hostkey_verify=self._hostkey_verify)
        elif self._auth_method is "key":
            self._mgr = manager.connect(host=self._conn[0],
                                        port=self._conn[1],
                                        username=self._auth[0],
                                        key_filename=self._auth_key,
                                        hostkey_verify=self._hostkey_verify)
        else:
            raise ValueError("auth_method incorrect value.")
        self._mgr.timeout = 600

        return True
530786
function doReconnect() {
    //
    // Cleanup and recreate the socket associated
    // with this instance.
    //
    self.retry.waiting = true;
    self.socket.removeAllListeners();
    self.socket = common.createSocket(self._options);

    //
    // Cleanup reconnect logic once the socket connects
    //
    self.socket.once('connect', function () {
      self.retry.waiting = false;
      self.retry.retries = 0;
    });

    //
    // Attempt to reconnect the socket
    //
    self._setup();
    self.connect();
  }
904299
def _reconnect_cb(self):
        """"""
        @asyncio.coroutine
        def try_reconnect():
            """Actual coroutine ro try to reconnect or reschedule."""
            try:
                yield from self._do_connect()
            except IOError:
                self._loop.call_later(SERVER_RECONNECT_DELAY,
                                      self._reconnect_cb)
        asyncio.ensure_future(try_reconnect())
5869
def _maybe_reconnect(self):
    """"""
    with self._lock:
      if not self._connected: 
        _LOGGER.info("Connecting")
        self._do_login_locked()
        self._connected = True
        self._connect_cond.notify_all()
        _LOGGER.info("Connected")
1226041
def reconnect(self):
        
        self.connect(*self._saved_connect.args, **self._saved_connect.kwargs)
388111
static function getConnection($db_name=null) {
		if (null === $db_name) {
			$keys = array_keys(self::$parameters);
			$db_name = reset($keys);
		}

		if (!@$db_name) {
			return null;
		}

		return self::connect($db_name);
	}
1054913
def reconnect(self):
        '''
        '''
        if self._connection.closed():
            self._connection.reset()

            yield from self._connection.connect()
764710
public function reconnect()
    {
        if (is_callable($this->reconnector)) {
            $this->doctrineConnection = null;

            return call_user_func($this->reconnector, $this);
        }

        throw new LogicException('Lost connection and no reconnector available.');
    }
1159020
public function db_connect($persistent = FALSE)
	{
		$error = NULL;
		$conn_id = ($persistent === TRUE)
			? sqlite_popen($this->database, 0666, $error)
			: sqlite_open($this->database, 0666, $error);

		isset($error);

		return $conn_id;
	}
379752
public function reconnect($client = null)
    {
        $this->waitConnectNum ++;
        if ($client == null) {
            $client = new \swoole_mysql();
            $client->genTime = time();
        }
        $set = $this->config['mysql'][$this->active];
        $client->connect($set, function ($client, $result) use ($set) {
            $this->waitConnectNum --;
            if (! $result) {
                getInstance()->log->error($client->connect_error . ' with Mysql ' . $set['host'] . ':' . $set['port']);
            } else {
                $client->isClose = false;
                if (! isset($client->client_id)) {
                    $client->client_id = $this->establishedConn;
                    $this->establishedConn ++;
                }
                $this->pushToPool($client);
            }
        });
        $client->on('Close', [
            $this,
            'onClose'
        ]);
    }
738488
function connect(&$err)
		{
			if (!function_exists('memcache_pconnect')) {
				$err = 'Memcache module PECL extension not found!';
				return false;
			}

			$memcache = new MemCache;

			if (!is_array($this->hosts)) $this->hosts = array($this->hosts);

			$failcnt = 0;
			foreach($this->hosts as $host) {
				if (!@$memcache->addServer($host,$this->port,true)) {
					$failcnt += 1;
				}
			}
			if ($failcnt == sizeof($this->hosts)) {
				$err = 'Can\'t connect to any memcache server';
				return false;
			}
			$this->_connected = true;
			$this->_memcache = $memcache;
			return true;
		}
1223005
private function __disconnect()
    {
        if (is_null($this->memcache)) {
            return;
        }
        $this->memcache->close();
        $this->memcache = null;

        return true;
    }
1191604
public function isAlive($reconnect = false)
    {
        if (!$this->driver->systype($this->resource)) {
            if ($reconnect) {
                return $this->connect();
            }

            return false;
        }

        return true;
    }
1247383
private int getNewReconnectIvl()
    {
        //  The new interval is the current interval + random value.
        int interval = currentReconnectIvl + (Utils.randomInt() % options.reconnectIvl);

        //  Only change the current reconnect interval  if the maximum reconnect
        //  interval was set and if it's larger than the reconnect interval.
        if (options.reconnectIvlMax > 0 && options.reconnectIvlMax > options.reconnectIvl) {
            //  Calculate the next interval
            currentReconnectIvl = Math.min(currentReconnectIvl * 2, options.reconnectIvlMax);
        }
        return interval;
    }
836301
protected function reconnect()
    {
        if ($this->connection->inTransaction()) {
            // It is not safe to blindly reconnect in the middle of a transaction
            return false;
        }

        try {
            // Make sure we free any resources associated with the old connection
            $this->connection->disconnect();
        } catch (Exception $e) {
        }

        try {
            $this->connection->connect();
            $this->connection->log('[RECONNECT]');

            return true;
        } catch (Exception $e) {
            // If there was an error connecting again, don't report it back,
            // let the retry handler do it.
            return false;
        }
    }
1089835
public function disconnect()
    {
        for ($i = 0; $i < $this->getParam('retryAttempts') + 1; $i++) {
            $res = @ftp_close($this->connection);

            if (false !== $res) {
                $this->connection = null;
                break;
            }
        }

        return $this;
    }