我的代码是这样的:
if( ($this->master=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0 )
{
die("socket_create() failed, reason: ".socket_strerror($this->master));
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的php文件与web套接字创建连接时,我收到错误致命错误:调用行中的未定义函数socket_create()if(($ this-> master = socket_create(AF_INET,SOCK_STREAM,SOL_TCP))<0)
因此,我无法连接Web套接字,也无法从套接字获取响应消息,因为在运行客户端页面时,我的浏览器中显示Socket Status:3(Closed).
你知道缺少什么吗?先感谢您.
我使用javascript连接websocket:
<script>
var socket;
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
</script>
Run Code Online (Sandbox Code Playgroud)
我收到了错误:
无法与服务器建立连接
var host = "ws://localhost:8000/socket/server/startDaemon.php";
var socket = new WebSocket(host);
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
注意:我在mozilla中启用了websocket以支持Web套接字应用程序.当我在chrome中运行时出现错误:
can't establish a connection to the server at ws://localhost:8000/socket/server/startDaemon.php. var socket = new WebSocket(host);
Run Code Online (Sandbox Code Playgroud)