進(jìn)程服務(wù)端:
<?php
use Workerman\Worker;
use Workerman\Lib\Timer;
require_once './vendor/autoload.php';
$task_worker = new Worker('text://127.0.0.1:1122');
$task_worker->name = 'TaskWorker';
$task_worker->onMessage = function($connection, $task_data)
{
$connection->send($task_data);
};
Worker::runAll();
客戶端:
use Workerman\Worker;
use Workerman\Lib\Timer;
require_once './vendor/autoload.php';
$task_worker = new Worker('text://127.0.0.1:1122');
$task_worker->name = 'TaskWorker';
$task_worker->onMessage = function($connection, $task_data)
{
$connection->send($task_data);
};
Worker::runAll();
報(bào)錯(cuò)信息:
# php task.php
PHP Fatal error: Call to a member function add() on null in /home/wwwroot/default/workerman/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 203
Fatal error: Call to a member function add() on null in /home/wwwroot/default/workerman/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 203
# php task.php
PHP Fatal error: Call to a member function add() on null in /home/wwwroot/default/workerman/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 203
Fatal error: Call to a member function add() on null in /home/wwwroot/default/workerman/vendor/workerman/workerman/Connection/AsyncTcpConnection.php on line 203。
通過Terminal連接服務(wù)端是可以的。
這個(gè)是學(xué)習(xí)http://doc3.workerman.net/faq/async-task.html,稍作改動了下。
謝謝;