|
45 | 45 | var sys = require('sys'), |
46 | 46 | http = require('http'); |
47 | 47 | http.createServer(function (req, res) { |
48 | | - setTimeout(function () { |
49 | | - res.writeHead(200, {'Content-Type': 'text/plain'}); |
50 | | - res.end('Hello World\n'); |
51 | | - }, 2000); |
| 48 | + res.writeHead(200, {'Content-Type': 'text/plain'}); |
| 49 | + res.end('Hello World\n'); |
52 | 50 | }).listen(8124, "127.0.0.1"); |
53 | 51 | sys.puts('Server running at http://127.0.0.1:8124/'); |
54 | 52 | </pre> |
@@ -129,15 +127,13 @@ <h2 id="about">About</h2> |
129 | 127 |
|
130 | 128 | <p> |
131 | 129 | Node's goal is to provide an easy way to build scalable network |
132 | | - programs. In the above example, the two second delay does not |
133 | | - prevent the server from handling new requests. Node tells the |
| 130 | + programs. In the "hello world" web server example above, many |
| 131 | + client connections can be handled concurrently. Node tells the |
134 | 132 | operating system (through <code>epoll</code>, <code>kqueue</code>, |
135 | 133 | <code class="sh_none">/dev/poll</code>, or <code>select</code>) |
136 | | - that it should be notified when the 2 seconds are up or if a new |
137 | | - connection is made—then it goes to sleep. If someone new |
138 | | - connects, then it executes the callback, if the timeout expires, |
139 | | - it executes the inner callback. Each connection is only a small |
140 | | - heap allocation. |
| 134 | + that it should be notified when a new connection is made, and |
| 135 | + then it goes to sleep. If someone new connects, then it executes |
| 136 | + the callback. Each connection is only a small heap allocation. |
141 | 137 | </p> |
142 | 138 |
|
143 | 139 | <p> |
@@ -196,12 +192,16 @@ <h2 id="about">About</h2> |
196 | 192 | passing. In future versions, Node will be able to fork new |
197 | 193 | processes (using the <a |
198 | 194 | href="http://www.whatwg.org/specs/web-workers/current-work/"> Web |
199 | | - Workers API </a>), but this is something that fits well into the |
200 | | - current design. |
| 195 | + Workers API </a>) which fits well into the current design. |
201 | 196 | </p> |
202 | 197 |
|
203 | 198 | <p> |
204 | | - See also: <a href="http://s3.amazonaws.com/four.livejournal/20091117/jsconf.pdf">slides</a> from jsconf. |
| 199 | + See also: |
| 200 | + <ul> |
| 201 | + <li><a href="http://s3.amazonaws.com/four.livejournal/20091117/jsconf.pdf">slides</a> from JSConf 2009</li> |
| 202 | + <li><a href="http://nodejs.org/jsconf2010.pdf">slides</a> from JSConf 2010</li> |
| 203 | + <li><a href="http://www.yuiblog.com/blog/2010/05/20/video-dahl/">video</a> from a talk at Yahoo in May 2010</li> |
| 204 | + </ul> |
205 | 205 | </p> |
206 | 206 |
|
207 | 207 |
|
|
0 commit comments