Jump to content

Node.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m deprod
Azakhark (talk | contribs)
Section 'External links' is added
Line 20: Line 20:
server.listen(7000, "localhost");
server.listen(7000, "localhost");
</pre>
</pre>

== External links ==
[http://nodejs.org/ Official website]


{{Compu-lang-stub}}
{{Compu-lang-stub}}

Revision as of 06:36, 22 March 2010

Node.js is an evented I/O toolkit [disambiguation needed] for V8 JavaScript engine.


An example of a simple TCP server which listens on port 7000 and echos whatever you send it:

var tcp = require('tcp');
var server = tcp.createServer(function (socket) {
  socket.setEncoding("utf8");
  socket.addListener("connect", function () {
    socket.send("hello\r\n");
  });
  socket.addListener("receive", function (data) {
    socket.send(data);
  });
  socket.addListener("eof", function () {
    socket.send("goodbye\r\n");
    socket.close();
  });
});
server.listen(7000, "localhost");

Official website