Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_length_check 开启下,自动拼拆业务包 #31

Open
shenzhe opened this issue Aug 3, 2018 · 0 comments
Open

open_length_check 开启下,自动拼拆业务包 #31

shenzhe opened this issue Aug 3, 2018 · 0 comments

Comments

@shenzhe
Copy link
Member

shenzhe commented Aug 3, 2018

现状


open_length_check是目前最常用的解决业务粘包的方式,

现在实际开发过程中大都会做如下事情:
send:
$client->send(pack($config['package_length_type'], strlen($sendData)).$sendData);

recv:
$recvData = $client->recv();
//省略了一些异常判断
return substr($recvData, $this->config['package_body_offset']);

问题


收发包操作频繁,一方面增加理解难度,另一方面也会带来一些性能损耗

改进


底层在内置pack和unpack方法
$client->send(package_pack($sendData));
$recvData = package_unpack($client->recv);

选项


@matyhtf matyhtf changed the title RFC-1011 open_length_check 开启下,自动拼拆业务包 open_length_check 开启下,自动拼拆业务包 Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant