【问题标题】:How to make a "server" PHP script communicate with other scripts如何使“服务器”PHP 脚本与其他脚本通信
【发布时间】:2013-07-20 07:21:18
【问题描述】:
【问题讨论】:
标签:
php
websocket
ratchet
【解决方案1】:
Ratchet 不提供客户端。我会为您的 php websocket 客户端查看 phpwebsocket。
为确保客户端连接来自 Ratchet 中的 localhost,请更改 Push Integration 教程中的这段代码:
// Set up our WebSocket server for clients wanting real-time updates
$webSock = new React\Socket\Server($loop);
// Binding to 0.0.0.0 means remotes can connect
//$webSock->listen(8080, '0.0.0.0');
// Binding to 127.0.0.1 means the only client that can connect is itself
$webSock->listen(8080, '127.0.0.1');
$webServer = new Ratchet\Server\IoServer(
new Ratchet\WebSocket\WsServer(
new Ratchet\Wamp\WampServer(
$pusher
)
),
$webSock
);
【解决方案2】:
您需要创建一个代理 PHP 脚本来处理 javascript 请求并将其转换为 CLI 命令到您的棘轮脚本。