swoole tcp连接

<?php

$serv= new swoole_server("0.0.0.0",9501);
/*
 $serv->on(string $event,mixed $callbank)
 $event:  connect:建立连接 
                    $serv:服务器信息; $fd : 客户端信息
          receive:当接受到数据
                    $serv:服务器信息; $fd : 客户端信息
                    $from_id :id ,$data:数据
                    
          close:关闭,链接

*/
$serv->on('connect',function($serv,$fd){
    
    echo "建立连接
";
    
});
$serv->on('receive',function($serv,$fd,$from_id ,$data){
    
    echo "收到数据
";
    
});

$serv->on('close',function($serv,$fd){
    
    echo "关闭
";
});

$serv->start();
##########################################################################

1,上传代码到服务器,
2 切换到站点目录
   

3 运行

  

4 查看是否运行

我们可以在Shell里运行,使用pstree查看进程模型结构: 

[root@root ftpname]# pstree -ap|grep index.php
| | `-php,4058 index.php
| | |-php,4059 index.php
| | | |-php,4062 index.php
| | | |-php,4063 index.php
| | | |-php,4064 index.php
| | | `-php,4065 index.php
| |-grep,4067 --color=auto index.php
[root@root ftpname]#

 4 关闭防火墙; 开启服务

5  测试





##########################################################################





原文地址:https://www.cnblogs.com/benpaodegegen/p/10208954.html