Connect.

@return true, if successful
973536
public boolean connect(){
		try {
			sock = new Socket(host, port);
			in = new BufferedReader(new InputStreamReader(
					sock.getInputStream(), "UTF-8"));
			out = new BufferedWriter(new OutputStreamWriter(
					sock.getOutputStream(), "UTF-8"));
			return true;
		}
		catch (Exception e){
			System.out.println(e.getMessage());
			return false;
		}
	}
244046
private function connect()
    {
        if ($this->isConnected()) {
            return $this;
        }

        $connectionString = sprintf(
            'host=%s port=%d dbname=%s user=%s password=%s sslmode=%s',
            $this->host,
            $this->port,
            $this->dbName,
            $this->username,
            $this->password,
            $this->sslMode ? 'require' : 'disable'
        );

        $this->pgConn = pg_connect($connectionString);
        if ($this->pgConn === false) {
            throw $this->createException('Can`t connect');
        }

        $this->pendingConnection = false;

        return $this;
    }
940269
public function connect()
    {
        if ($this->isConnected) {
            return false;
        }

        if (!$this->pdo) {
            $this->beforeConnect && call_user_func($this->beforeConnect, $this);

            $dsn = $this->getDsn();
            $attrs = $this->attrs + array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_STRINGIFY_FETCHES => true,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
            );

            try {
                $this->pdo = new PDO($dsn, $this->user, $this->password, $attrs);
            } catch (\PDOException $e) {
                $this->connectFails && call_user_func($this->connectFails, $this, $e);
                throw $e;
            }

            $this->afterConnect && call_user_func($this->afterConnect, $this, $this->pdo);
        }

        $this->isConnected = true;

        return true;
    }
837226
public function connect()
    {
        list($host, $port) = explode(':', $this->getServer());
        if ($this->stream->open($host, $port, $this->getTimeout()) === false) {
            throw new Exception(sprintf('Cannot connect to server %s', $this->getServer()), Exception::SERVER_OFFLINE);
        }

        return true;
    }
777019
public function connect()
    {
        Debug::Log(Debug::DEBUG, 'socket_connect()');
        if (!$this->context) {
            $context = stream_context_create();
        } else {
            $context = $this->context;
        }
        Debug::Log(Debug::DEBUG, 'socket_connect(): connect to='.$this->address);

        $this->socket = stream_socket_client(
            $this->address,
            $errno,
            $errstr,
            60,
            STREAM_CLIENT_CONNECT,
            $context
        );
        if (!$this->socket) {
            Debug::Log(Debug::DEBUG, "stream_socket_client() {$errno}, {$errstr}");
            return false;
        }
        stream_set_timeout($this->socket,  5);

        #TODO:  MUST BE IN BLOCKING MODE
        #$this->set_blocking();

        return true;
    }
678960
@Override
    synchronized public boolean connect(InetSocketAddress addr){
        long now = System.currentTimeMillis();
        if(isStarted){
            return true;
        }
        isStarted = true;

        String host = addr.getHostName();
        int port = addr.getPort();

        serverURI = URI.create("ws://" + host + ":" + port + "/ws/service/");

        if(LOGGER.isTraceEnabled()){
            LOGGER.trace("WebSocket connect to timeOut=" + connectTimeOut + " - " + serverURI.toString());
        }

        client = new WebSocketClient();

        doConnect();

        synchronized(sessionLock){
            long to = connectTimeOut - (System.currentTimeMillis() - now);
            while(! connected && to > 0){

                try {
                    sessionLock.wait(to);
                } catch (InterruptedException e) {
                    // do nothing.
                }
                to = connectTimeOut - (System.currentTimeMillis() - now);
            }
        }
        return true;
    }
1026155
protected function connect()
    {
        try {
            // Loop until we connect
            while (!$this->isConnected()) {
                // Assume we will connect, until we dont
                $this->setIsConnected(true);

                // Connect the socket
                $this->io->connect();

                $this->channels = array();
                // The connection object itself is treated as channel 0
                parent::__construct($this, 0);

                $this->input = new AMQPReader(null, $this->io);

                $this->write($this->amqp_protocol_header);
                $this->wait(array($this->waitHelper->get_wait('connection.start')),false,$this->connection_timeout);
                $this->x_start_ok(
                    $this->getLibraryProperties(),
                    $this->login_method,
                    $this->login_response,
                    $this->locale
                );

                $this->wait_tune_ok = true;
                while ($this->wait_tune_ok) {
                    $this->wait(array(
                        $this->waitHelper->get_wait('connection.secure'),
                        $this->waitHelper->get_wait('connection.tune')
                    ));
                }

                $host = $this->x_open($this->vhost, '', $this->insist);
                if (!$host) {
                    //Reconnected
                    $this->io->reenableHeartbeat();
                    return null; // we weren't redirected
                }

                $this->setIsConnected(false);
                $this->closeChannels();

                // we were redirected, close the socket, loop and try again
                $this->close_socket();
            }

        } catch (\Exception $e) {
            // Something went wrong, set the connection status
            $this->setIsConnected(false);
            $this->closeChannels();
            $this->close_input();
            $this->close_socket();
            throw $e; // Rethrow exception
        }
    }
952621
public function connect()
    {
        $this->connection = @new \mysqli(
            $this->host,
            $this->username,
            $this->password,
            $this->databaseName
        );

        if (!$this->connection->connect_errno) {
            $this->connection->autocommit(1);
            return true;
        } else {
            return false;
        }
    }
1301502
public function connect()
    {
        if ($this->_connection) {
            return true;
        }
        $config = $this->_config;
        $config['flags'] += [
            PDO::ATTR_PERSISTENT => $config['persistent'],
            PDO::ATTR_EMULATE_PREPARES => false,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        ];
        if (empty($config['unix_socket'])) {
            $dsn = "pgsql:host={$config['host']};port={$config['port']};dbname={$config['database']}";
        } else {
            $dsn = "pgsql:dbname={$config['database']}";
        }

        $this->_connect($dsn, $config);
        $this->_connection = $connection = $this->getConnection();
        if (!empty($config['encoding'])) {
            $this->setEncoding($config['encoding']);
        }

        if (!empty($config['schema'])) {
            $this->setSchema($config['schema']);
        }

        if (!empty($config['timezone'])) {
            $config['init'][] = sprintf('SET timezone = %s', $connection->quote($config['timezone']));
        }

        foreach ($config['init'] as $command) {
            $connection->exec($command);
        }

        return true;
    }
529101
public function connect()
    {
        $this->isBound = false;
        $this->connection = $this->driver->connect(
            $this->configuration['hostname'],
            $this->configuration['port'],
            $this->configuration['withSSL'],
            $this->configuration['withTLS']
        );

        foreach ($this->configuration['options'] as $key => $value) {
            $this->connection->setOption($key, $value);
        }
    }
1164656
public function connect(){
		if($this->connected !== false)
			return;

		$this->driver->connect($this->config);
		$this->connected = true;
		$this->notifyObservers(ObserverInterface::CONNECT);
	}
167002
public function connect()
    {
        try {
            // Instantiate an S3 client
            $this->setS3Client(new S3Client([
                        'version' => $this->supplier['version'],
                        'region' => $this->supplier['region'],
                        'http'    => $this->supplier['http']
                    ]
                )
            );
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
434509
public function connect()
    {
        $this->initialize();

        $riakClient = $this->riakClient;
        return $this->retry(function() use ($riakClient) {
            return $riakClient->connect();
        });
    }
1005234
function connect()
    {
        $db_config = $this->config;
        if (empty($db_config['persistent']))
        {
            $this->conn = mysql_connect($db_config['host'] . ':' . $db_config['port'],
                $db_config['user'],
                $db_config['passwd']);
        }
        else
        {
            $this->conn = mysql_pconnect($db_config['host'] . ':' . $db_config['port'],
                $db_config['user'],
                $db_config['passwd']);
        }
        if (!$this->conn)
        {
            Swoole\Error::info(__CLASS__." SQL Error", mysql_error($this->conn));
            return false;
        }
        mysql_select_db($db_config['name'], $this->conn) or Swoole\Error::info("SQL Error", mysql_error($this->conn));
        if ($db_config['setname'])
        {
            mysql_query('set names ' . $db_config['charset'], $this->conn) or Swoole\Error::info("SQL Error",
                mysql_error($this->conn));
        }
        return true;
    }
315057
public function connect(): bool
	{
		if ($this->ssl === true)
		{
			$this->connection = fsockopen('ssl://'.$this->host, $this->port);
		}
		else
		{
			$this->connection = fsockopen($this->host, $this->port);
		}

		return $this->connected();
	}
1043583
def connect(self):
        
        self.conn = self.db_module.connect(
                host=self.host, port=int(self.port), user=self.user,
                passwd=self.passwd, db=self.dbname, charset=self.charset,
                cursorclass=self.cursorclass)
        self.conn.autocommit(self.autocommit)
        return True
731385
public function connect() : bool
    {
        try {
            $connection_string = 'sqlsrv:SERVER=' . $this->configuration['server'] . ';DATABASE=' . $this->configuration['dbname'];
            if (isset($this->configuration['encrypt']) && true === $this->configuration['encrypt']) {
                $connection_string .= ';ENCRYPT=1';
            }
            $this->logger->debug('Connecting to database engine.');
            $this->dbconn = new PDO($connection_string, $this->configuration['username'],
                $this->configuration['password']);
            $this->dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $this->logger->debug('Connected to database engine.');
            $this->is_connected = true;
        } catch (\Exception $e) {
            throw new DatabaseConnectionException('MSSQL Connection to <strong>' . $this->configuration['server'] . '</strong> failed!<br>' . $e->getMessage());
        }
        return true;
    }