在windows中 $connection_to_hsm->onMessage能够得到返回的数据,linux中得不到,不知道我的代码写的是不是有问题?
$REAL_HSM_ADDRESS = 'tcp://127.0.0.1:6666';
// 监听本地6000端口
$hsm = new Worker('tcp://0.0.0.0:6000');
$hsm->count = 1;
$hsm->onConnect = function($connection)
{
global $REAL_HSM_ADDRESS;
$connection_to_hsm = new AsyncTcpConnection($REAL_HSM_ADDRESS);
$connection_to_hsm->onMessage = function($connection_to_hsm, $buffer)use($connection)
{
$connection->send($buffer);
};
// 执行异步连接
$connection_to_hsm->connect();
// 客户端发来数据时,转发给对应的连接
$connection->onMessage = function($connection, $buffer)use($connection_to_hsm)
{
$connection_to_hsm->send($buffer);
};