library/Rediska/Connection/Socket.php
public function connect() 
    {
        if ($this->isConnected()) {
            return false;
        }

        $this->_socket = $this->_createSocketConnection();

        // Throw exception if can't connect
        if (!is_resource($this->_socket)) {
            $errorCode = socket_last_error();
            $errorMessage = socket_strerror($errorCode);

            $msg = "Can't connect to Redis server on {$this->getHost()}:{$this->getPort()}";
            if ($errorCode || $errorMessage) {
                $msg .= "," . ($errorCode ? " error $errorCode" : "") . ($errorMessage ? " $errorMessage" : "");
            }

            $this->_socket = null;

            throw new Rediska_Connection_Exception($msg);
        }

        // Set read timeout
        if ($this->_options['readTimeout'] != null) {
            $this->setReadTimeout($this->_options['readTimeout']);
        }

        // Set blocking mode
        //if (1 || $this->_options['blockingMode'] == false) {
        //    $this->setBlockingMode($this->_options['blockingMode']);
        //}

        // Send password
        if ($this->getPassword() != '') {
            $auth = new Rediska_Connection_Exec($this, "AUTH {$this->getPassword()}");
            try {
               $auth->execute();
            } catch (Rediska_Command_Exception $e) {
                throw new Rediska_Connection_Exception("Password error: {$e->getMessage()}");
            }
        }

        // Set db
        if ($this->_options['db'] !== self::DEFAULT_DB) {
            $selectDb = new Rediska_Connection_Exec($this, "SELECT {$this->_options['db']}");
            try {
               $selectDb->execute();
            } catch (Rediska_Command_Exception $e) {
                throw new Rediska_Connection_Exception("Select db error: {$e->getMessage()}");
            }
        }

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

        $this->_socket = $this->_createSocketConnection();

        // Throw exception if can't connect
        if (!is_resource($this->_socket)) {
            $errorCode = socket_last_error();
            $errorMessage = socket_strerror($errorCode);

            $msg = "Can't connect to Redis server on {$this->getHost()}:{$this->getPort()}";
            if ($errorCode || $errorMessage) {
                $msg .= "," . ($errorCode ? " error $errorCode" : "") . ($errorMessage ? " $errorMessage" : "");
            }

            $this->_socket = null;

            throw new Rediska_Connection_Exception($msg);
        }

        // Set read timeout
        if ($this->_options['readTimeout'] != null) {
            $this->setReadTimeout($this->_options['readTimeout']);
        }

        // Set blocking mode
        //if (1 || $this->_options['blockingMode'] == false) {
        //    $this->setBlockingMode($this->_options['blockingMode']);
        //}

        // Send password
        if ($this->getPassword() != '') {
            $auth = new Rediska_Connection_Exec($this, "AUTH {$this->getPassword()}");
            try {
               $auth->execute();
            } catch (Rediska_Command_Exception $e) {
                throw new Rediska_Connection_Exception("Password error: {$e->getMessage()}");
            }
        }

        // Set db
        if ($this->_options['db'] !== self::DEFAULT_DB) {
            $selectDb = new Rediska_Connection_Exec($this, "SELECT {$this->_options['db']}");
            try {
               $selectDb->execute();
            } catch (Rediska_Command_Exception $e) {
                throw new Rediska_Connection_Exception("Select db error: {$e->getMessage()}");
            }
        }

        return true;
    }
Connect to redis server

@throws Rediska_Connection_Exception
@return boolean