小编San*_*Jha的帖子

致命错误:调用未定义的函数socket_create()

我的代码是这样的:

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).

你知道缺少什么吗?先感谢您.

php

51
推荐指数
4
解决办法
10万
查看次数

无法在ws:// localhost:8000/socket/server/startDaemon.php建立与服务器的连接.var socket = new WebSocket(host);

我使用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)

php html5 websocket phpwebsocket

14
推荐指数
2
解决办法
4万
查看次数

标签 统计

php ×2

html5 ×1

phpwebsocket ×1

websocket ×1