请帮我把WebSocket连接到php。
我尝试了这段代码,但我收到了400条错误请求
$fp = fsockopen("cs.money", 443, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br />n";
}
else
{
$out = "GET / HTTP/1.1rnrn";
///Send data
fwrite($fp, $out);
///Receive data - in small chunks :)
while (!feof($fp))
{
echo fgets($fp, 128);
}
fclose($fp);
}
答案 0 :(得分:0)
我用js解决了我的问题。
var WebSocket = require('ws');
var ws = new WebSocket('wss://cs.money/ws');