$body_header_len) { $header = substr($content,$start,$body_header_len); if(!is_numeric($header)) { return; } $body_len = intval($header); if($body_len == 0) { //这是一个心跳包 $start += $body_header_len; $left -= $body_header_len; } else { if($left >= $body_header_len + $body_len) { $body = substr($content,$start + $body_header_len,$body_len); // $this->mProcessor->onRequest($fd,$body); $start += $body_header_len + $body_len; $left -= $body_header_len + $body_len; } else { break; } } } if($start > 0) { $str = substr($content,$start); if($str === false) { return ''; } else { return $str; } } return $content; } function ev_read($buffer, $id) { $content = ''; while ($read = event_buffer_read($buffer, 1024)) { echo $read; $content .= $read; $content = proc($content); echo $content; // var_dump($read); } } ?>