protected function write($data) { if ($this->debug) { MiscHelper::debug_msg("< [hex]:\n" . MiscHelper::hexdump($data, $htmloutput = false, $uppercase = true, $return = true)); } $len = strlen($data); while (true) { if (false === ($written = fwrite($this->sock, $data))) { throw new Exception("Error sending data"); } if ($written === 0) { throw new Exception("Broken pipe or closed connection"); } $len = $len - $written; if ($len > 0) { $data = substr($data, 0 - $len); } else { break; } } }
/** * @param string $data */ public function debug_hexdump($data) { if ($this->debug) { $this->debug_msg(sprintf('< [hex]: %s%s', PHP_EOL, MiscHelper::hexdump($data, $htmloutput = false, $uppercase = true, $return = true))); } }