app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
protected function _read() {
        $code = null;
        $len = -1;
        while ( ! feof($this->_varnishConn)) {
            $response = fgets($this->_varnishConn, self::READ_CHUNK_SIZE);
            if (empty($response)) {
                $streamMeta = stream_get_meta_data($this->_varnishConn);
                if ($streamMeta['timed_out']) {
                    Mage::throwException('Varnish admin socket timeout');
                }
            }
            if (preg_match('~^(\d{3}) (\d+)~', $response, $match)) {
                $code = (int) $match[1];
                $len = (int) $match[2];
                break;
            }
        }

        if (is_null($code)) {
            Mage::throwException('Failed to read response code from Varnish');
        } else {
            $response = array('code' => $code, 'text' => '');
            while ( ! feof($this->_varnishConn) &&
                    strlen($response['text']) < $len) {
                $response['text'] .= fgets($this->_varnishConn,
                    self::READ_CHUNK_SIZE);
            }
            return $response;
        }
    }
protected function _read() {
        $code = null;
        $len = -1;
        while ( ! feof($this->_varnishConn)) {
            $response = fgets($this->_varnishConn, self::READ_CHUNK_SIZE);
            if (empty($response)) {
                $streamMeta = stream_get_meta_data($this->_varnishConn);
                if ($streamMeta['timed_out']) {
                    Mage::throwException('Varnish admin socket timeout');
                }
            }
            if (preg_match('~^(\d{3}) (\d+)~', $response, $match)) {
                $code = (int) $match[1];
                $len = (int) $match[2];
                break;
            }
        }

        if (is_null($code)) {
            Mage::throwException('Failed to read response code from Varnish');
        } else {
            $response = array('code' => $code, 'text' => '');
            while ( ! feof($this->_varnishConn) &&
                    strlen($response['text']) < $len) {
                $response['text'] .= fgets($this->_varnishConn,
                    self::READ_CHUNK_SIZE);
            }
            return $response;
        }
    }
protected function _read ( ) { $ code = null ; $ len = - 1 ; while ( ! feof ( $ this -> _varnishConn ) ) { $ response = fgets ( $ this -> _varnishConn , self :: READ_CHUNK_SIZE ) ; if ( empty ( $ response ) ) { $ streamMeta = stream_get_meta_data ( $ this -> _varnishConn ) ; if ( $ streamMeta [ 'timed_out' ] ) { Mage :: throwException ( 'Varnish admin socket timeout' ) ; } } if ( preg_match ( '~^(\d{3}) (\d+)~' , $ response , $ match ) ) { $ code = ( int ) $ match [ 1 ] ; $ len = ( int ) $ match [ 2 ] ; break ; } } if ( is_null ( $ code ) ) { Mage :: throwException ( 'Failed to read response code from Varnish' ) ; } else { $ response = array ( 'code' => $ code , 'text' => '' ) ; while ( ! feof ( $ this -> _varnishConn ) && strlen ( $ response [ 'text' ] ) < $ len ) { $ response [ 'text' ] .= fgets ( $ this -> _varnishConn , self :: READ_CHUNK_SIZE ) ; } return $ response ; } }
Read a response from Varnish instance

@return array tuple of the response (code, text)
Read a response from Varnish instance