通过ad hoc将两台计算机连接到节点js服务器

时间:2014-11-22 00:33:49

标签: javascript node.js networking adhoc

我想知道如何在一台机器上托管节点服务器,然后在另一台机器上通过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');

0 个答案:

没有答案
相关问题