Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在wamp上运行套接字以及本地主机使用哪个端口_Php_Node.js_Sockets - Fatal编程技术网

Php 如何在wamp上运行套接字以及本地主机使用哪个端口

Php 如何在wamp上运行套接字以及本地主机使用哪个端口,php,node.js,sockets,Php,Node.js,Sockets,我第一次在我的项目中使用node.js,我正在WAMP上运行我的项目 我已经创建了app.js,我的app.js的代码是: 我的客户端html是: <!DOCTYPE html> <html> <head> <title>Server Time poller</title> <meta charset="UTF-8"> </head> <body> <div id="statusMessageD

我第一次在我的项目中使用node.js,我正在WAMP上运行我的项目

我已经创建了app.js,我的app.js的代码是:

我的客户端html是:

<!DOCTYPE html>
<html>
<head>
<title>Server Time poller</title>
<meta charset="UTF-8">
</head>
<body>
<div id="statusMessageDiv">

</div>
<div id="serverTimeDiv"></div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">     </script>
<script src="192.168.0.204:3000/socket.io/socket.io.js"></script>
<script>


$(document).ready(function(){
alert('hello');
var socket = io.connect('http://192.168.0.204:8080');

socket.on('testEvent',function(data){
$("#statusMessageDiv").html(data.welcomeMessage);
socket.emit('testRevert',{message:'acknowledged'});
 });
socket.on('timeUpdate', function (data) {
$("#serverTimeDiv").html(data.currentTime);
});
});
</script>
</html>
但当我在浏览器中打开index.html时,会收到“hello”警报,然后出现错误

ReferenceError: io is not defined
 var socket = io.connect('http://192.168.0.204:8080');

请提供帮助。

正确查看后,我认为问题在于您的端口:

您在此处使用端口3000:


您的应用程序运行在端口
8080

端口如何?您正在使用一次端口3000和另一次端口8080
info - socket.io started.
ReferenceError: io is not defined
 var socket = io.connect('http://192.168.0.204:8080');