/*------------------------------------------------------ */ //-- 需要安装websocket,我用的是下面链接提供的 //-- https://github.com/Textalk/websocket-php /*------------------------------------------------------ */ //客户端 require('vendor/autoload.php'); $client = new WebSocket\Client("ws://124.222.224.186:8800"); $client->text("Hello WebSocket.org!"); echo $client->receive(); $client->close(); //服务端 $server = new WebSocket\Server(); $server->accept(); $message = $server->receive(); $server->text($message); $server->close();
标签:WebSocket,text,server,client,Websocket,websocket,PHP,客户端 From: https://www.cnblogs.com/shenqilun/p/17761125.html