/** * Reads from the buffer. When more data is required reads another entire * chunk and serves future reads out of that. * * @param int $len How much data */ public function read($len) { if (!$this->read_) { return $this->transport_->read($len); } if (strlen($this->rBuf_) === 0) { $this->readFrame(); } // Just return full buff if ($len >= strlen($this->rBuf_)) { $out = $this->rBuf_; $this->rBuf_ = null; return $out; } // Return substr $out = substr($this->rBuf_, 0, $len); $this->rBuf_ = substr($this->rBuf_, $len); return $out; }
public function read($len) { if (strlen($this->rBuf_) === 0) { $this->rBuf_ = $this->transport_->read($this->rBufSize_); } if (strlen($this->rBuf_) <= $len) { $ret = $this->rBuf_; $this->rBuf_ = ''; return $ret; } $ret = substr($this->rBuf_, 0, $len); $this->rBuf_ = substr($this->rBuf_, $len); return $ret; }
/** * Reads from the buffer. When more data is required reads another entire * chunk and serves future reads out of that. * * @param int $len How much data */ public function read($len) { if (!$this->read_) { return $this->transport_->read($len); } if (strlen($this->rBuf_) === 0) { $this->readFrame(); } // Return substr $out = substr($this->rBuf_, $this->rIndex_, $len); $this->rIndex_ += $len; if (strlen($this->rBuf_) <= $this->rIndex_) { $this->rBuf_ = null; $this->rIndex_ = 0; } return $out; }
/** * Reads from the buffer. When more data is required reads another entire * chunk and serves future reads out of that. * * @param int $len How much data */ public function read($len) { if (!$this->read_) { return $this->transport_->read($len); } if (strlen($this->rBuf_) - $this->rBufIdx_ <= 0) { $this->readFrame(); } // Just return full buff if ($len >= strlen($this->rBuf_) - $this->rBufIdx_) { $out = substr($this->rBuf_, $this->rBufIdx_); $this->rBuf_ = null; $this->rBufIdx_ = 0; return $out; } // Return substr $out = substr($this->rBuf_, $this->rBufIdx_, $len); $this->rBufIdx_ += $len; //$this->rBuf_ = substr($this->rBuf_, $len); return $out; }
/** * Reads from the buffer. When more data is required reads another entire * chunk and serves future reads out of that. * * @param int $len How much data */ public function read($len) { if (!$this->read_) { return $this->transport_->read($len); } if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { $this->readFrame(); } // Just return full buff if ($len >= TStringFuncFactory::create()->strlen($this->rBuf_)) { $out = $this->rBuf_; $this->rBuf_ = null; return $out; } // Return TStringFuncFactory::create()->substr $out = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); return $out; }