塔吊/塔机数据监控
1、模拟发送通信命令,创建client文件,通过cli跑文件:
PHP Code复制内容到剪贴板
- $client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
- $client->on("connect", function($cli) {
- echo "连接成功,开始发送数据:\r\n";
- $d = 'a55a3101010671714ac9130403102a2b01f40000000013380bb8a4000000000000020000000000000000010056cc33c33c';
- $data = pack("H*",$d);
- $cli->send($data);
- });
- $client->on("receive", function($cli, $data){
- echo "received: {$data}\n";
- });
- $client->on("error", function($cli){
- echo "connect failed\n";
- });
- $client->on("close", function($cli){
- echo "connection close\n";
- });
- $client->connect("0.0.0.0", 9512, 0.5);
2、建立tcp服务器,通过9502端口接收数据:
PHP Code复制内容到剪贴板
- <?php
- define('TCP_PORT', '9502');//tcp端口号
- define('MYSQL_HOST', 'mysql');
- define('MYSQL_PORT', 3306);
- define('MYSQL_USER', 'root');
- define('MYSQL_PASSWORD', '123456,');
- define('MYSQL_DATABASE', 'test');
- define('MYSQL_TABLE_PREFIX', 'yoyocmf_'); // 数据库前缀
- define('PID_FILE', '/var/www/html/logs/9502.pid');// 线程ID
- define('LOG_FILE', '/var/www/html/logs/9502.log');// 日志地址
- class TcpServer
- {
- public $server;
- public function __construct()
- {
- $serv = new swoole_server("0.0.0.0", TCP_PORT);
- $serv->set([
- 'daemonize' => true, // 设置守护进程模式
- 'log_file' => LOG_FILE,
- 'task_worker_num' => 4, // 4个task
- // 'open_eof_split' => true, //打开EOF_SPLIT检测
- // 'package_eof' => "\r\n", //设置EOF,onReceive每次仅收到一个以EOF字串结尾的数据包
- 'max_request' => 1000, // 防止 PHP 内存溢出, 一个工作进程处理 X 次任务后自动重启 (注: 0,不自动重启)用于worker进程
- 'task_max_request' => 1000, // 防止 PHP 内存溢出
- 'pid_file' => PID_FILE, // 这里可以使用一键重启环境
- ]);
- $serv->on('connect', [$this, 'onConnect']);
- //监听数据接收事件
- $serv->on('receive', [$this, 'onReceive']);
- $serv->on('WorkerStart', [$this, 'onWorkerStart']);
- $serv->on('task', [$this, 'onTask']);
- $serv->on('finish', [$this, 'onFinish']);
- $serv->on('close', [$this, 'onClose']);
- $this->server = $serv;
- $serv->start();
- }
- public function onConnect($server, $fd)
- {
- echo "Client: Connect.\n"; // 连接成功
- }
- /**
- * worker中 用到的时候就用协程mysql就行
- * @param $server
- * @param $worker_id
- */
- public function onWorkerStart($server, $worker_id)
- {
- if ($server->taskworker === true) {
- echo date('Y-m-d H:i:s') . " task : " . $worker_id . " start" . PHP_EOL;
- } else {
- echo date('Y-m-d H:i:s') . " worker : " . $worker_id . " start" . PHP_EOL;
- }
- }
- public function onReceive($serv, $fd, $from_id, $data)
- {
- // echo date("Y-m-d H:i:s") . "转换后数据 => " . bin2hex($data) . "\n\n\n";
- // // 转换塔吊发过来的命令字符串
- // $commandStr = bin2hex($data);
- // 转换塔吊命令为数组,一个字节,代表一个数组,第几个字节,就是第几个数组,如果其他硬件,注意unpack都是正数,如果有负数,要看文档,比如温度等
- $commandPack = unpack("C*", $data);
- /**
- * TODO 判断帧头是否为0xA55A
- * 帧头是两个字节,三套解决方案
- * 一、 截取十六进制字符串前四个字符串,判断是否为a55a (substr($commandStr, 0, 4))
- * 二、 判断 数组[1] == 0xa5 && 数组[2] == 0x5a
- * 三、 判断 (数组[1] << 8) + 数组[2] = (0xa55a的十进制数值) (本次用第三套)
- * 如果是三个字节:arr[1] << (8*2) 加 arr[2] << 8 加 arr[3]
- * 如果是四个字节:arr[1] << (8*3) 加 arr[2] << (8*2) 加 arr[3] << 8 加 arr[4]
- * 以上是大端的方法,即高字节在前,低字节在后(一般协议都是这种)
- * 小端反过来,低字前在前,高字节在后
- */
- $commandHead = ($commandPack[1] << 8) + $commandPack[2]; //帧头是2字节,获取帧头的十进制值
- if ($commandHead == 0xA55A) {
- $serv->task([
- "commandStr" => bin2hex($data),
- "commandPack" => $commandPack
- ]);
- } else {
- echo "数据不合法,十进制帧头为:" . $commandHead . PHP_EOL;
- return false;
- }
- $serv->send($fd, "Server: Receiving completed \n");
- }
- /**
- * 任务处理 先写入redis数据,再判断数量写入mysql库
- * @param $server
- * @param $task_id
- * @param $from_id
- * @param $data
- * @return string
- */
- public function onTask($server, $task_id, $from_id, $data)
- {
- $commandStr = $data["commandStr"];
- $commandPack = $data["commandPack"];
- $res = $this->AnalyzePackage($commandStr, $commandPack);
- // echo $res["errmsg"] . "\n";
- $server->finish("insert DB -> OK");
- }
- /**
- * 解析设备注册 / 设备参数上报
- * @param string $str
- * @param array $arr
- * @return array
- */
- function AnalyzePackage($str = "", $arr = array())
- {
- // echo date("Y-m-d H:i:s").":" . $str . PHP_EOL;
- $res = [
- "errcode" => 1,
- "errmsg" => "未解析"
- ];
- // print_r($arr);
- // 获取帧尾,固定八位为Cc33c33c
- $commandTail = substr($str, -8); //Cc33c33c
- if ($commandTail != "cc33c33c") {
- return [
- "errcode" => 1,
- "errmsg" => "上报数据命令有误" . $str
- ];
- }
- // 判断响应帧类型 来区分,注册和参数上报,整改在判断的时候,各种进制是通用的
- $commandResponse = $arr[6];
- if ($commandResponse == 0x00) {
- // 设备注册请求
- $res = [
- "errcode" => 0,
- "errmsg" => "设备注册请求"
- ];
- } else if ($commandResponse == 0x01) {
- // 设备注册响应
- $res = [
- "errcode" => 0,
- "errmsg" => "设备注册响应"
- ];
- } else if ($commandResponse == 0x02) {
- // 设备参数上报
- $res = [
- "errcode" => 0,
- "errmsg" => "设备参数上报"
- ];
- } else if ($commandResponse == 0x06) {
- // 实时数据上报
- $res = [
- "errcode" => 0,
- "errmsg" => "实时数据上报"
- ];
- // 7.8.9.10 是设备编号
- $code = [
- $arr[7],
- $arr[8],
- $arr[9],
- $arr[10]
- ];
- // 设备编号,6-10帧位
- $deviceCode = $this->getDecimalSumInt($code); // 这个是十进制数字,将指定帧数的值相加
- $sendYear = $arr[11] + 2000; //年,年为2000+
- $sendMonth = $arr[12];//月
- $sendDay = $arr[13]; //日
- $sendHour = $arr[14]; //时
- $sendMin = $arr[15]; //分
- $sendSec = $arr[16]; //秒
- // 上传时间,年月日时分秒
- $sendTime = $sendYear . "-" . $sendMonth . "-" . $sendDay . " " . $sendHour . ":" . $sendMin . ":" . $sendSec;
- // 高度(单位:米)
- // ($arr[17] << 8) + $arr[18]
- // $arr[17] * 256 + $arr[18]
- $gd = $this->getDecimalSumInt([$arr[17],$arr[18]]);//$arr[17] * 256 + $arr[18] 也可以
- // 幅度(单位:米)
- $fd = $this->getDecimalSumInt([$arr[19],$arr[20]]);
- // 回转(单位:度)
- $rotate = $this->getDecimalSumInt([$arr[21],$arr[22]]);
- // 载重(单位:KG)
- $load = $this->getDecimalSumInt([$arr[23],$arr[24]]);
- // 当前允许载重(单位:KG)
- $loadAllow = $this->getDecimalSumInt([$arr[25],$arr[26]]);
- // 载重百分比(单位:百分点)
- $loadPercentage = $arr[27];
- // 风速(单位:米/秒)
- $windSpeed = $this->getDecimalSumInt([$arr[28],$arr[29]]);
- // 倾斜(单位:度)
- $tilt = $this->getDecimalSumInt([$arr[30],$arr[31]]);
- // 高度限位值 报警
- $heightLimit = $arr[32];
- $gdWarn = $heightLimit & 0x0f; // 获取高度限位值 低四位,00正常 01预警 02报警
- $heightHighFour = ($heightLimit & 0xf0) >> 4; // 获取高度限位值 高四位
- // 幅度回转限位 报警
- $widthLimit = $arr[33];
- $fdNWarn = $widthLimit & 0x0f; // 获取幅度回转限位值 低四位,低4bit:00正常 01近端限位预警 02近端限位报警
- $fdZWarn = ($widthLimit & 0xf0) >> 4; // 获取幅度回转限位值 高四位,高4bit:00正常 01左限位预警 02左限位报警 03右限位预警 04右限位报警
- // 载重限制值 报警
- $loadWarn = $arr[34];
- // 倾斜风速限制 报警
- $tiltLimit = $arr[35];
- $tiltFsWarn = $tiltLimit & 0x0f; // 获取倾斜风速限制 低四位,00风速正常 01风速预警 02风速报警
- $tiltQxWarn = ($tiltLimit & 0xf0) >> 4; // 获取倾斜风速限制 高四位,00倾斜正常 01倾斜预警 02倾斜报警
- // 干涉上下限位 报警
- $topBottomLimit = $arr[36];
- $topWarn = $topBottomLimit & 0x0f; // 干涉上下限位 低四位,00上限位正常 01上限位预警 02上限位报警
- $bottomWarn = ($topBottomLimit & 0xf0) >> 4; // 干涉上下限位 高四位,00下限位正常 01下限位预警 02下限位报警
- // 干涉前后限位 报警
- $frontBackendLimit = $arr[37];
- $frontWarn = $frontBackendLimit & 0x0f; // 干涉前后限位 低四位,00前限位正常 01前限位预警 02前限位报警
- $backWarn = ($frontBackendLimit & 0xf0) >> 4; // 干涉前后限位 高四位,00后限位正常 01后限位预警 02后限位报警
- // 干涉左右限位 报警
- $leftRightLimit = $arr[38];
- $leftWarn = $leftRightLimit & 0x0f; // 干涉左右限位 低四位,00左限位正常 01左限位预警 02左限位报警
- $rightWarn = ($leftRightLimit & 0xf0) >> 4; // 干涉左右限位 高四位,00右限位正常 01右限位预警 02右限位报警
- // 碰撞上下限位 报警
- $CollideTopBottomLimit = $arr[39];
- $CollideTopWarn = $CollideTopBottomLimit & 0x0f; // 碰撞上下限位 低四位,00上限位正常 01上限位预警 02上限位报警
- $CollideBottomWarn = ($CollideTopBottomLimit & 0xf0) >> 4; // 碰撞上下限位 高四位,00下限位正常 01下限位预警 02下限位报警
- // 碰撞前后限位 报警
- $CollideFrontBackendLimit = $arr[40];
- $CollideFrontWarn = $CollideFrontBackendLimit & 0x0f; // 碰撞前后限位 低四位,00前限位正常 01前限位预警 02前限位报警
- $CollideBackendWarn = ($CollideFrontBackendLimit & 0xf0) >> 4; // 干涉前后限位 高四位,00后限位正常 01后限位预警 02后限位报警
- // 碰撞左右限位 报警
- $CollideLeftRightLimit = $arr[41];
- $CollideLeftWarn = $CollideLeftRightLimit & 0x0f; // 干涉左右限位 低四位,00左限位正常 01左限位预警 02左限位报警
- $CollideRightWarn = ($CollideLeftRightLimit & 0xf0) >> 4; // 干涉左右限位 高四位,00右限位正常 01右限位预警 02右限位报警
- // 继电器状态
- $jdq = $arr[42];
- $jdqStatus = $this->getBitByByte($jdq); //只取六个,分别属于:上下前后左右
- // [
- // 0 => 0,
- // 1 => 0,
- // 2 => 0,
- // 3 => 0,
- // 4 => 0,
- // 5 => 0,
- // 6 => 0,
- // 7 => 0
- // ];
- $workStatus = $arr[43];
- // 传感器状态
- $cgq = $arr[44];
- $cgqStatus = $this->getBitByByte($cgq); //只取六个,分别属于:高度/幅度/回转/重量/风速/倾斜
- $created_at = time();
- $insert = [
- "code" => $deviceCode,
- "gd" => $gd / 10, //单位 0.1米
- "fd" => $fd / 10, //单位 0.1米
- "rotate" => $rotate / 10, //单位 0.1米
- "load" => $load,
- "load_allow" => $loadAllow,
- "load_percentage" => $loadPercentage,
- "wind_speed" => $windSpeed / 10, //单位 0.1米/秒
- "tilt" => $tilt / 100, // 单位 0.01度
- "receive_time" => $sendTime,
- "created_at" => $created_at,
- "year" => date("Y", $created_at),
- "month" => date("m", $created_at),
- "day" => date("d", $created_at),
- "gd_warn" => $gdWarn,
- "fd_warn" => $fdNWarn . "|" . $fdZWarn,
- "load_warn" => $loadWarn,
- "tilt_warn" => $tiltFsWarn . "|" . $tiltQxWarn,
- "top_bottom_warn" => $topWarn . "|" . $bottomWarn,
- "front_backend_warn" => $frontWarn . "|" . $backWarn,
- "left_right_warn" => $leftWarn . "|" . $rightWarn,
- "collide_top_bottom_warn" => $CollideTopWarn . "|" . $CollideBottomWarn,
- "collide_front_backend_warn" => $CollideFrontWarn . "|" . $CollideBackendWarn,
- "collide_left_right_warn" => $CollideLeftWarn . "|" . $CollideRightWarn,
- "jdq" => $jdqStatus[0] . "|" . $jdqStatus[1] . "|" . $jdqStatus[2] . "|" . $jdqStatus[3] . "|" . $jdqStatus[4] . "|" . $jdqStatus[5],
- "work_status" => $workStatus,
- "cgq" => $cgqStatus[0] . "|" . $cgqStatus[1] . "|" . $cgqStatus[2] . "|" . $cgqStatus[3] . "|" . $cgqStatus[4] . "|" . $cgqStatus[5],
- "ydata" => $str
- ];
- go(function () use ($insert) {
- $tablename = MYSQL_TABLE_PREFIX . "monitor_tower_data";// 环境监测数据表名
- $swoole_mysql = new Swoole\Coroutine\MySQL();
- $swoole_mysql->connect([
- 'host' => MYSQL_HOST,
- 'port' => MYSQL_PORT,
- 'user' => MYSQL_USER,
- 'password' => MYSQL_PASSWORD,
- 'database' => MYSQL_DATABASE,
- ]);
- $field = "";
- $value = "";
- foreach ($insert as $k => $v) {
- $field .= "`$k`,";
- $value .= "'$v',";
- }
- $field = rtrim($field, ',');
- $value = rtrim($value, ',');
- $sql = "INSERT INTO {$tablename} (".$field.") VALUES (".$value.")";
- // echo $sql . "\n";
- $ret = $swoole_mysql->query($sql);
- // var_dump($ret);
- });
- // echo "设备编号:" . $deviceCode . "\n";
- // echo "上传时间:" . $sendTime . "\n";
- // echo "高度:" . $gd . "米\n";
- // echo "幅度:" . $fd . "米\n";
- // echo "回转:" . $rotate . "度\n";
- // echo "载重:" . $load . "KG\n";
- // echo "当前允许载重:" . $loadAllow . "KG\n";
- // echo "载重百分比:" . $loadPercentage . "%\n";
- // echo "风速:" . $windSpeed . "米/秒\n";
- // echo "倾斜:" . $tilt . "度\n";
- //
- // if ($gdWarn == 1) {
- // echo "高度限位预警:" . "预警" . "\n";
- // } else if ($gdWarn == 2) {
- // echo "高度限位预警:" . "报警" . "\n";
- // } else {
- // echo "高度限位预警:" . "正常" . "\n";
- // }
- //
- // if ($fdZWarn == 1) {
- // echo "幅度回转限位:" . "左限位预警" . "\n";
- // } else if ($fdZWarn == 2) {
- // echo "幅度回转限位:" . "左限位报警" . "\n";
- // } else if ($fdZWarn == 3) {
- // echo "幅度回转限位:" . "右限位预警" . "\n";
- // } else if ($fdZWarn == 4) {
- // echo "幅度回转限位:" . "右限位报警" . "\n";
- // } else {
- //// echo "幅度回转限位:" . "正常" . "\n";
- // }
- //
- // if ($fdNWarn == 1) {
- // echo "幅度回转限位:" . "近端限位预警" . "\n";
- // } else if ($fdNWarn == 2) {
- // echo "幅度回转限位:" . "近端限位报警" . "\n";
- // } else if ($fdNWarn == 3) {
- // echo "幅度回转限位:" . "远端限位预警" . "\n";
- // } else if ($fdNWarn == 4) {
- // echo "幅度回转限位:" . "远端限位报警" . "\n";
- // } else {
- //// echo "幅度回转限位:" . "正常" . "\n";
- // }
- //
- // if ($loadWarn == 1) {
- // echo "载重限制:" . "载重预警" . "\n";
- // } else if ($loadWarn == 2) {
- // echo "载重限制:" . "载重报警" . "\n";
- // } else if ($loadWarn == 3) {
- // echo "载重限制:" . "违章" . "\n";
- // } else {
- // echo "载重限制:" . "正常" . "\n";
- // }
- //
- // if ($tiltFsWarn == 1) {
- // echo "风速限制:" . "风速预警" . "\n";
- // } else if ($tiltFsWarn == 2) {
- // echo "风速限制:" . "风速报警" . "\n";
- // } else {
- // echo "风速限制:" . "风速正常" . "\n";
- // }
- //
- // if ($tiltQxWarn == 1) {
- // echo "倾斜限制:" . "倾斜预警" . "\n";
- // } else if ($tiltQxWarn == 2) {
- // echo "倾斜限制:" . "倾斜报警" . "\n";
- // } else {
- // echo "倾斜限制:" . "倾斜正常" . "\n";
- // }
- //
- // if ($topWarn == 1) {
- // echo "上限位预警" . "\n";
- // } else if ($topWarn == 2) {
- // echo "上限位报警" . "\n";
- // } else {
- // echo "上限位正常" . "\n";
- // }
- //
- // if ($bottomWarn == 1) {
- // echo "下限位预警" . "\n";
- // } else if ($bottomWarn == 2) {
- // echo "下限位报警" . "\n";
- // } else {
- // echo "下限位正常" . "\n";
- // }
- //
- // if ($frontWarn == 1) {
- // echo "前限位预警" . "\n";
- // } else if ($frontWarn == 2) {
- // echo "前限位报警" . "\n";
- // } else {
- // echo "前限位正常" . "\n";
- // }
- //
- // if ($backWarn == 1) {
- // echo "后限位预警" . "\n";
- // } else if ($backWarn == 2) {
- // echo "后限位报警" . "\n";
- // } else {
- // echo "后限位正常" . "\n";
- // }
- //
- // if ($leftWarn == 1) {
- // echo "左限位预警" . "\n";
- // } else if ($leftWarn == 2) {
- // echo "左限位报警" . "\n";
- // } else {
- // echo "左限位正常" . "\n";
- // }
- //
- // if ($rightWarn == 1) {
- // echo "右限位预警" . "\n";
- // } else if ($rightWarn == 2) {
- // echo "右限位报警" . "\n";
- // } else {
- // echo "右限位正常" . "\n";
- // }
- //
- // if ($CollideTopWarn == 1) {
- // echo "碰撞上限位预警" . "\n";
- // } else if ($CollideTopWarn == 2) {
- // echo "碰撞上限位报警" . "\n";
- // } else {
- // echo "碰撞上限位正常" . "\n";
- // }
- //
- // if ($CollideBottomWarn == 1) {
- // echo "碰撞下限位预警" . "\n";
- // } else if ($CollideBottomWarn == 2) {
- // echo "碰撞下限位报警" . "\n";
- // } else {
- // echo "碰撞下限位正常" . "\n";
- // }
- //
- // if ($CollideFrontWarn == 1) {
- // echo "碰撞前限位预警" . "\n";
- // } else if ($CollideFrontWarn == 2) {
- // echo "碰撞前限位报警" . "\n";
- // } else {
- // echo "碰撞前限位正常" . "\n";
- // }
- //
- // if ($CollideBackendWarn == 1) {
- // echo "碰撞后限位预警" . "\n";
- // } else if ($CollideBackendWarn == 2) {
- // echo "碰撞后限位报警" . "\n";
- // } else {
- // echo "碰撞后限位正常" . "\n";
- // }
- //
- // if ($CollideLeftWarn == 1) {
- // echo "碰撞左限位预警" . "\n";
- // } else if ($CollideLeftWarn == 2) {
- // echo "碰撞左限位报警" . "\n";
- // } else {
- // echo "碰撞左限位正常" . "\n";
- // }
- //
- // if ($CollideRightWarn == 1) {
- // echo "碰撞右限位预警" . "\n";
- // } else if ($CollideRightWarn == 2) {
- // echo "碰撞右限位报警" . "\n";
- // } else {
- // echo "碰撞右限位正常" . "\n";
- // }
- // exit();
- }
- return $res;
- }
- /**
- * 指定数组,或运算 返回int值 / 【int结果之间判断对等,不分进制】
- * 如果是三个字节:arr[1] << (8*2) 加 arr[2] << 8 加 arr[3]
- * 如果是四个字节:arr[1] << (8*3) 加 arr[2] << (8*2) 加 arr[3] << 8 加 arr[4]
- * 以上是大端的方法,即高字节在前,低字节在后(一般协议都是这种)
- * 小端反过来,低字前在前,高字节在后
- * @param array $arr
- * @return int
- */
- function getDecimalSumInt($arr = array())
- {
- $sum = 0;
- $count = count($arr);
- foreach ($arr as $k => $v) {
- $no = $count - ($k + 1);
- $sum |= $v << (8 * $no); // 或运算,和 += 一样的结果
- }
- // // 打印公式
- // for ($i = 0; $i < $count; $i++) {
- // $no = $count - ($i + 1);
- // if ($no > 0) {
- // $sum .= "$arr[$i] << (8 * " . ($count - ($i + 1)) . ") + ";
- // } else {
- // $sum .= "$arr[$i]";
- // }
- // }
- return $sum;
- }
- /**
- * 根据字节返回每一位
- * @param int $byte
- * @return array
- */
- function getBitByByte($byte = 0)
- {
- $res = [];
- for ($i = 7; $i >= 0; $i--) {
- // $res[$i] = ($byte & 1); //小端,从左到右
- $res[] = ($byte & 1); // 大端,从右到左
- $byte = ($byte >> 1);
- }
- return $res;
- }
- /**
- * tcp服务器关闭
- * @param $ser
- * @param $fd
- */
- public function onClose($ser, $fd)
- {
- echo "client {$fd} closed\n";
- }
- public function onFinish($server, $task_id, $data)
- {
- // echo "AsyncTask[$task_id] finished: {$data}\n";
- }
- }
- // new TcpServer();
- if (!isset($argv[1])) {
- $argv[1] = 'restart';
- }
- if ($argv[1] == 'start') {
- echo "server start at " . date('Y-m-d H:i:s') . "\n";
- new TcpServer();
- } elseif ($argv[1] == 'stop') {
- if (file_exists(PID_FILE) && swoole_process::kill(file_get_contents(PID_FILE), 0)) {
- swoole_process::kill(file_get_contents(PID_FILE), SIGTERM);
- if (file_exists(PID_FILE)) {
- unlink(PID_FILE);
- }
- echo "server stop at " . date('Y-m-d H:i:s') . "\n";
- } else {
- echo "server not exist" . "\n";
- }
- } elseif ($argv[1] == 'restart') {
- if (file_exists(PID_FILE) && swoole_process::kill(file_get_contents(PID_FILE), 0)) {
- $pid = file_get_contents(PID_FILE);
- swoole_process::kill($pid, SIGTERM);
- while (true) {
- if (!swoole_process::kill($pid, 0)) {
- break;
- }
- usleep(100000);
- }
- if (file_exists(PID_FILE)) {
- unlink(PID_FILE);
- }
- echo "server restart at " . date('Y-m-d H:i:s') . "\n";
- new TcpServer();
- } else {
- echo "server start at " . date('Y-m-d H:i:s') . "\n";
- new TcpServer();
- }
- }
启动TCP Server:
php server9512.php start 启动
php server9512.php stop 停止
php server9512.php restart 平滑重启