Hi Stef,
I don't think that the buzz around NodeJS comes from these samples of
code. Yes, it's very easy to starting a project with NodeJS but the
interest from NodeJS is that this server extends the usages of
Javascript wich becomes an language useable on many platform, many OS
for many usages. With Javascript, programmers can write client code in
browsers, widgets for desktop computers, shell scripts with Rhino,
mobile applications for Android or IOS, ... and now, programmers can
write server code for web applications and web services.
My two cents
Olivier ;-)
www.auverlot.fr
Hi guys
apparently people get excited by nodeJS and I would like to know the
equivalence of
var http = require('http');
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('Server running at http://127.0.0.1:1337/');
To run the server, put the code into a file example.js and execute it with the
node program:
% node example.js
Server running at http://127.0.0.1:1337/
Here is an example of a simple TCP server which listens on port 1337 and echoes
whatever you send it:
var net = require('net');
var server = net.createServer(function (socket) {
socket.write("Echo server\r\n");
socket.pipe(socket);
});
server.listen(1337, "127.0.0.1");
we should communicate better :)
Stef