当前位置:首页 > PHP > 正文内容

Benchmarking 127.0.0.1 (be patient)...apr_socket_recv

高老师6年前 (2020-08-31)PHP1749

当我用ab进行对php socket代码进行并发测试出现问题,经过排查是我直接对客户端进行发送消息,没有先读取客户端消息造成的。

   
$text = "hello world" . PHP_EOL;
fwrite($conn, $text);
fclose($conn);

修改为

//读取client发送的信息
$client_msg = fread($conn, 1024);
echo 'client_msg:' . $client_msg . PHP_EOL;

//发送消息给client
$text = "hello world" . PHP_EOL;
fwrite($conn, $text);
fclose($conn);

ok

扫描二维码推送至手机访问。

版权声明:本文由高久峰个人博客发布,如需转载请注明出处。

本文链接:https://blog.20230611.cn/post/153.html

分享给朋友:

“Benchmarking 127.0.0.1 (be patient)...apr_socket_recv” 的相关文章

PHP中$this和self的区别

PHP中$this和self的区别

<?php //对比$this和self   /*  * $this更倾向于对象本身  *   */   class  Par{     public   ...

Thinkphp Call Stack,PHP调用栈Call Stack的获取

Thinkphp Call Stack,PHP调用栈Call Stack的获取

ThinkPHP中有一个debug调试功能,能输出报错文件的信息,并能看到这个函数被哪些函数调用,从框架的启动开始记录,特别方便调试。于是研究了下它的底层给予了实现。<?php //--框架核心--Start //框架内置错误处理 function errDealWith($er...

PHP getenv函数和putenv函数的学习

PHP getenv函数和putenv函数的学习

(1).在PHP中可以查看的环境变量包括: (1.1).电脑环境变量 (2.1).服务器环境变量(2).getenv()函数获取一个环境变量的值.参数1是环境变量的key,参数2值为true的时候仅从你的电脑环境变量中查找,参数2值为false会从两种变量中全部查询//获取我电脑登录的用户名,输出A...

PHP Warning:  ftok(): Project identifier is invalid

PHP Warning: ftok(): Project identifier is invalid

在使用ftok生成ipc进程通信key尝试将第二个参数项目标识符传入字符串报错:PHP Warning:  ftok(): Project identifier is invalid,查阅资料发现第二个字符串只能是1个字符串,长度为1....

packagist包发布稳定版

packagist包发布稳定版

自己的composer已经发布到packagist,但是无法使用composer require easy-task/easy-task来安装,只能在配置文件使用如下方式安装:"require": {     "easy...

PHP Startup: Unable to load dynamic library 'C:\php\ext\php_curl.dll找不到指定的模块

PHP Startup: Unable to load dynamic library 'C:\php\ext\php_curl.dll找不到指定的模块

最近在编写windows php多线程的东西,从官网下载了PHP的线程安全版,尝试开启curl扩展extension=php_curl.dllphp -m 却提示 PHP Startup: Unable to load dynamic library 'C:\php\ext\php_curl...