This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http.createServer(dispatchRequest).listen(port); | |
function dispatchRequest(req, res) | |
{ | |
res.sentinel = new Sentinel(function (e) { | |
// Like a catch() clause that catches callbacks too. | |
// Called if handleRequest throws, or if any of the callbacks | |
// registered by handleRequest throw, or if any of the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'), | |
http = require('http'); | |
http.createServer(function (req, res) { | |
setTimeout(function () { | |
res.sendHeader(200, {'Content-Type': 'text/plain'}); | |
res.sendBody('Hello World'); | |
res.finish(); | |
}, 2000); | |
}).listen(3000); | |
sys.puts('Server running at http://127.0.0.1:3000/'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node helloworld.js | |
Server running at http://127.0.0.1:3000/ | |
# At this point in another terminal I use netcat to open a plain TCP connection, | |
# and then Ctrl-C to close the connection without having sent any data. | |
# node then blows up with: | |
Segmentation Fault | |
NewerOlder