Skip to content

Instantly share code, notes, and snippets.

@michealbenedict
Created July 11, 2012 20:08
Show Gist options
  • Save michealbenedict/3092953 to your computer and use it in GitHub Desktop.
Save michealbenedict/3092953 to your computer and use it in GitHub Desktop.
basic script
var net = require('net');
var http = require('http');
// Echo Server
net.createServer(function(socket) {
socket.on('data', function(data) {
console.log(data.toString());
socket.write(data);
});
}).listen(4000);
console.log('Echo running at http://127.0.0.1:4000/');
// http server
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('HTTP Server running at http://127.0.0.1:1337/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment