先贴出php的代码 php 内核方面关于 zend api 以后有时间会再做 学习的
$server = new Server("0.0.0.0", 9501);
$server->set(array(
'worker_num' => 1,
'daemonize' => true,
// 'max_request' => 50000,
// 'dispatch_mode' => 2,
// 'package_max_length' => 4096,
'open_length_check' => true,
'package_length_offset' => 0,
'package_body_offset' => 0,
'package_length_type' => "N",//0 后 N(4位)是长度
'open_cpu_affinity' => true,
'log_file' => dirname(__FILE__) . '/log/socket.log'
));
$server->on('connect', function ($server, $fd){