/** * @param Core_Helper_Net_Tcp $tcp * @param int $timeoutsec * @return string */ public static function readHeader($tcp, $timeoutsec = 2) { $header = ''; do { $line = $tcp->fgets(self::MAX_LINE_SIZE, $timeoutsec); $header .= $line; if ($line == "\r\n") { break; } if ($tcp->getErrno() != 0) { break; } } while (!$tcp->feof()); return $header; }