1
헬륨 소켓 테스트를 원하는 모든 신체가 연결될 때 경고가 나타나야합니다. 노드 js가 설치되어 있지만 다른 컴퓨터에는 설치되지 않은 컴퓨터에서 작동합니다.연결이 거부 됨 노드 js
오류 :
Failed to load resource: net::ERR_CONNECTION_REFUSED http://xxx.xxx.xxx.xxx:8080/socket.io/socket.io.js Uncaught ReferenceError: io is not defined
코드 : 서버 :
var http = require('http');
var fs = require('fs');
var io = require('socket.io');
var server = http.createServer(function(req,res){
res.writeHead(200,{'Content-Type' : 'text/html'});
fs.readFile('./index.html',function(err,content){
res.end(content);
});
}).listen(8080);
io = io.listen(server)
io.sockets.on('connection',function(client){
client.emit('connecte');
});
클라이언트 :
<html>
<meta charset='utf-8'/>
<head>
<title>my first page</title>
<script src="http://localhost:8080/socket.io/socket.io.js" ></script>
</head>
<body>
<h1>It work</h1>
</body>
<script>
var socket;
socket = io.connect('http://localhost:8080');
socket.on('connecte', function(){
alert('You are connected');
});
</script>
</html>
영어를 유감스럽게 생각하며 영어를 배우려하지 않습니다. 감사합니다