Node.js 如何在远程服务器上使用socket.io?

Node.js 如何在远程服务器上使用socket.io?,node.js,sockets,socket.io,Node.js,Sockets,Socket.io,我正在尝试实现socket.io,但在随后的教程中,我说要将server.js连接到本地index.html文件: var server = http.createServer(function(req, res) { fs.readFile('./index.html', 'utf-8', function(error, content) { res.writeHead(200, {"Content-Type": "text/html"}); res.end(content);

我正在尝试实现socket.io,但在随后的教程中,我说要将server.js连接到本地index.html文件:

var server = http.createServer(function(req, res) {
fs.readFile('./index.html', 'utf-8', function(error, content) {
    res.writeHead(200, {"Content-Type": "text/html"});
    res.end(content);
});
}))

由于我的站点文件位于另一台服务器上,我如何连接到具有socket.io的远程服务器。以及如何在不加载index.html文件的情况下实例my server.js


(我只想了解web套接字的基本知识:发送和接收消息)

在服务器1提供的index.html中,您需要引用服务器2提供的socket.io脚本,然后可以连接到它var socket=io.connect(“http://[SERVER2 IP]:[PORT]”);谢谢,我只是创建了一个index.html文件,里面没有任何内容(在服务器2上)?不,在服务器2上不需要任何html!!它很有魅力