Browse Source

Web site example fixes.

v0.7.4-release
Matt Ranney 15 years ago
committed by Ryan Dahl
parent
commit
cec775a0de
  1. 38
      doc/index.html

38
doc/index.html

@ -33,12 +33,12 @@
<p id="introduction"> <p id="introduction">
Evented I/O for Evented I/O for
<a href="http://code.google.com/p/v8/">V8 javascript</a>. <a href="http://code.google.com/p/v8/">V8 JavaScript</a>.
</p> </p>
<p> <p>
An example of a web server written with Node which responds with An example of a web server written in Node which responds with
"Hello World" after waiting two seconds: "Hello World" for every request.
</p> </p>
<pre> <pre>
@ -49,14 +49,14 @@ http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'}); res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n'); res.end('Hello World\n');
}, 2000); }, 2000);
}).listen(8124); }).listen(8124, "127.0.0.1");
sys.puts('Server running at http://127.0.0.1:8124/');</pre> sys.puts('Server running at http://127.0.0.1:8124/');
</pre> </pre>
<p> <p>
To run the server, put the code into a file To run the server, put the code into a file
<code>example.js</code> and execute it with the <code>node</code> <code>example.js</code> and execute it with the <code>node</code>
program program:
</p> </p>
<pre class="sh_none"> <pre class="sh_none">
% node example.js % node example.js
@ -64,25 +64,24 @@ Server running at http://127.0.0.1:8124/</pre>
<p> <p>
Here is an example of a simple TCP server which listens on port 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:
</p> </p>
<pre> <pre>
var tcp = require('tcp'); var net = require('net');
var server = tcp.createServer(function (socket) { net.createServer(function (socket) {
socket.setEncoding("utf8"); socket.setEncoding("utf8");
socket.addListener("connect", function () { socket.addListener("connect", function () {
socket.write("hello\r\n"); socket.write("Echo server\r\n");
}); });
socket.addListener("data", function (data) { socket.addListener("data", function (data) {
socket.write(data); socket.write(data);
}); });
socket.addListener("end", function () { socket.addListener("end", function () {
socket.write("goodbye\r\n");
socket.end(); socket.end();
}); });
}); }).listen(8124, "127.0.0.1");
server.listen(8124);</pre> </pre>
<p> <p>
See the <a href="api.html">API documentation</a> for more See the <a href="api.html">API documentation</a> for more
@ -109,7 +108,7 @@ server.listen(8124);</pre>
tested on <b>Linux</b>, <b>Macintosh</b>, and <b>Solaris</b>. The tested on <b>Linux</b>, <b>Macintosh</b>, and <b>Solaris</b>. The
build system requires Python 2.4 or better. V8, on which Node is 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 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. There are no other dependencies.
</p> </p>
@ -143,12 +142,11 @@ make install</pre>
<p> <p>
This is in contrast to today's more common concurrency model where This is in contrast to today's more common concurrency model where
OS threads are employed. Thread-based networking OS threads are employed. Thread-based networking is relatively
<a href="http://www.sics.se/~joe/apachevsyaws.html">is</a> inefficient and very difficult to use. See:
<a href="http://www.kegel.com/c10k.html">relatively</a> <a href="http://www.sics.se/~joe/apachevsyaws.html">this,</a>
<a href="http://bulk.fefe.de/scalable-networking.pdf">inefficient</a> <a href="http://www.kegel.com/c10k.html">this,</a> and
<!-- TODO needs links --> <a href="http://bulk.fefe.de/scalable-networking.pdf">this.</a>
and very difficult to use.
Node will show much better memory efficiency under high-loads Node will show much better memory efficiency under high-loads
<!-- TODO benchmark --> <!-- TODO benchmark -->

Loading…
Cancel
Save