![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
swoole
张高伟
人生最美的是相遇,最难得的是相逢!
展开
-
tcp异步
<?php/** * Created by PhpStorm. * User: Administrator * Date: 2018/4/6 * Time: 22:59 *///创建TCP服务器$serv=new swoole_server('192.168.1.234',9154);//设置异步和进程工作数$serv->set(['task_worker_num...原创 2018-04-07 15:53:47 · 312 阅读 · 0 评论 -
实现实时异步任务队列
用户打开了我们的网站。他要做的就是勾选需要发邮件的代理商列表,然后把结算邮件发出去。假如我们需要发1封邮件,我们写个函数执行即可。考虑到网络可能会稍微有点延迟,但是是可以接受的,用户会乖乖等你的网页发完邮件了再关闭网页。假如我们要发布10封邮件,用一个for循环,循环10遍执行发邮件操作。这时候,也许10倍的网络延迟会让用户稍微有点不耐烦,但勉强可以等吧。假如要发100封邮件,for循环100遍,...转载 2018-04-08 16:08:28 · 875 阅读 · 0 评论 -
异步发送邮件
建立执行异步任务的tcp服务器$serv = new swoole_server("127.0.0.1", 9501);//设置异步任务的工作进程数量$serv->set(array('task_worker_num' => 4));$serv->on('receive', function($serv, $fd, $from_id, $data) { //投递...原创 2018-04-09 14:09:43 · 603 阅读 · 0 评论 -
建立tcp服务器
<?php/** * Created by PhpStorm. * User: Administrator * Date: 2018/4/3 * Time: 16:00 *///创建服务器 TCP服务器$serv = new swoole_server('192.168.1.234', 9502, SWOOLE_PROCESS, SWOOLE_SOCK_TCP);//监...原创 2018-04-06 16:48:37 · 980 阅读 · 0 评论 -
建立websocket服务器
1. webSocketServer.php<?php/** * Created by PhpStorm. * User: Administrator * Date: 2018/4/6 * Time: 16:49 */$server = new swoole_websocket_server('192.168.1.234', 9503);$server->on('o...原创 2018-04-06 17:20:14 · 790 阅读 · 0 评论 -
完成定时
<?php/** * Created by PhpStorm. * User: Administrator * Date: 2018/4/6 * Time: 17:25 */swoole_timer_tick(2000,function($timer_id){ echo "循环执行".$timer_id."\n";});swoole_timer_after...原创 2018-04-06 17:30:44 · 129 阅读 · 0 评论 -
http直接访问index.html
$http = new swoole_http_server("0.0.0.0", 9501);$http->set( [ 'enable_static_handler'=>true, 'document_root'=>'/data/apps/operation/abc' ]);$http->on('request', ...原创 2018-04-26 18:24:42 · 36727 阅读 · 2 评论 -
Linux环境下Php安装swoole扩展
php安装目录:/usr/local/phpphp.ini配置文件路径:/usr/local/php/etc/php.ini1、安装swoolecd /usr/local/srcwget https://github.com/swoole/swoole-src/archive/v2.1.3.tar.gztar zxvf v2.1.3.tar.gzcd swoole-src-...转载 2019-05-13 18:51:04 · 352 阅读 · 0 评论