diff --git a/doc/index.html b/doc/index.html index 5c7f9d72c6..f516a48b2a 100644 --- a/doc/index.html +++ b/doc/index.html @@ -33,12 +33,12 @@
Evented I/O for - V8 javascript. + V8 JavaScript.
- An example of a web server written with Node which responds with - "Hello World" after waiting two seconds: + An example of a web server written in Node which responds with + "Hello World" for every request.
@@ -49,14 +49,14 @@ http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }, 2000); -}).listen(8124); -sys.puts('Server running at http://127.0.0.1:8124/');+}).listen(8124, "127.0.0.1"); +sys.puts('Server running at http://127.0.0.1:8124/');
To run the server, put the code into a file
example.js
and execute it with the node
- program
+ program:
% node example.js @@ -64,25 +64,24 @@ Server running at http://127.0.0.1:8124/
Here is an example of a simple TCP server which listens on port 8124 - and echos whatever you send it: + and echoes whatever you send it:
-var tcp = require('tcp'); -var server = tcp.createServer(function (socket) { +var net = require('net'); +net.createServer(function (socket) { socket.setEncoding("utf8"); socket.addListener("connect", function () { - socket.write("hello\r\n"); + socket.write("Echo server\r\n"); }); socket.addListener("data", function (data) { socket.write(data); }); socket.addListener("end", function () { - socket.write("goodbye\r\n"); socket.end(); }); -}); -server.listen(8124);+}).listen(8124, "127.0.0.1"); +
See the API documentation for more @@ -109,7 +108,7 @@ server.listen(8124); tested on Linux, Macintosh, and Solaris. The build system requires Python 2.4 or better. V8, on which Node is built, supports only IA-32 and ARM processors. V8 is included in the - Node distribution. To use TLS, OpenSSL are required. + Node distribution. To use TLS, OpenSSL is required. There are no other dependencies.
@@ -143,12 +142,11 @@ make installThis is in contrast to today's more common concurrency model where - OS threads are employed. Thread-based networking - is - relatively - inefficient - - and very difficult to use. + OS threads are employed. Thread-based networking is relatively + inefficient and very difficult to use. See: + this, + this, and + this. Node will show much better memory efficiency under high-loads