/** * Reads until specified number of bytes has been read. * * @param int $bytesToRead */ protected function readExactly(int $bytesToRead) { $data = ''; while ($bytesToRead > 0) { $chunk = (yield $this->client->read($bytesToRead)); $bytesToRead -= strlen($chunk); $data .= $chunk; } (yield $data); }
public function parse() { do { $this->event = false; $buf = $this->buf = $this->handler->read(JAVA_RECV_SIZE); $len = strlen($buf); if (!xml_parse($this->parser, $buf, $len == 0)) { $this->handler->protocol->handler->shutdownBrokenConnection(sprintf("protocol error: %s,%s at col %d. Check the back end log for OutOfMemoryErrors.", $buf, xml_error_string(xml_get_error_code($this->parser)), xml_get_current_column_number($this->parser))); } } while (!$this->event || $this->level > 0); }