Browse Source

修改包体最大传输数量为20m

master
ubuntu20 4 years ago
parent
commit
f2701e83e7
  1. 7
      examples/client.php
  2. 2
      src/Pack.php
  3. 4
      src/RpcServer.php

7
examples/client.php

@ -16,7 +16,7 @@ function remoteCall(string $host, $port, string $data) {
$client->set(array(
'open_length_check' => true,
'package_max_length' => 81920,
'package_max_length' => 1024 * 1024 * 20,
'package_length_type' => 'N',
'package_length_offset' => 9,
'package_body_offset' => 13
@ -44,8 +44,9 @@ function remoteCall(string $host, $port, string $data) {
return $ret['data'];
}
$ret = remoteCall("127.0.0.1", "5188", '{"controller":"site","methor":"test","params":{"id":1}}');
//$data = '{"controller":"site","methor":"test","params":{"id":1}}';
$data = file_get_contents("/mnt/hgfs/wdev/data.txt");
$ret = remoteCall("127.0.0.1", "5188", $data);
//'{"controller":"site","methor":"test","params":{"id":"111"}}
//'{"controller":"site","methor":"test","params":{"id":1,"status":0}}'

2
src/Pack.php

@ -23,7 +23,7 @@ class Pack {
/**
* @var integral 包的最大长度
*/
static public $packageMaxLength = 1024 * 20;
static public $packageMaxLength = 1024 * 1024 * 20;
/**
* @var char 储存包体长度的字节数,N代表大端字节序的4个字节

4
src/RpcServer.php

@ -59,7 +59,9 @@ class RpcServer extends BaseService {
public function handle(int $fd, string $data) {
$_SERVER['data'] = $data;
try {
$ret = include $this->entryPoint;
//$ret = include $this->entryPoint;
echo $data."\n";
$ret = "sa";
$this->send($fd, $ret);
} catch (\Error $e) {
//TODO 记录日志

Loading…
Cancel
Save