我想知道如何在一台机器上托管节点服务器,然后在另一台机器上通过ad hoc连接,连接到该节点服务器。这是一个简单的服务器,我只需要显示问候语,但只适用于localhost:3000。
var http = require('http');
var counter = 1000; //to count invocations of function(req,res)
http.createServer(function (request,response){
//var requestURL = request.url;
//write HTTP header
response.writeHead(200, {'Content-Type': 'text/plain'});
//end HTTP response and provide final data to send
response.end('Request[' + counter++ + ']' + '\n'
+ 'hey!: ' + request.url + '\n');
}).listen(3000, "127 .0 .0 .1");
console.log('Server Running at http:// 127 0.0.1:3000/ CNTL-C to quit');