Connecting two computers over ad hoc to node js server

828 views Asked by At

I was wondering how i would go about hosting a node server on one machine and then connected by ad hoc on another machine, connect to that node server. This is a simple server I have sofar that just displays a greeting, but only works on 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

There are 0 answers