我正在尝试学习如何将 socket.io 与 phonegap/cordova 一起使用。这些教程教如何在 cmd 上使用 node.js,但没有教如何在我的网站服务器上启动它。
var http = require('http');
var server = http.createServer(function(request, response){
console.log('Connection');
response.writeHead(200, {'Content-Type': 'text/html'});
response.write('hello world');
response.end();
});
server.listen(8001);
到目前为止,我有这段代码可以通过“node server.js”运行,连接到http://localhost:8001将显示“hello world”。如何在诸如 HostMonster 之类的东西上执行此操作?我对编程很陌生,不能完全理解这一点。此外,如果您碰巧知道任何可以详细解释事物的好的 socket.io 教程,我们将不胜感激!谢谢!