Node.js

From air
Revision as of 12:42, 24 February 2013 by Donsez (talk | contribs)
Jump to navigation Jump to search

Node.js est un canevas pour réaliser des applications serveur en Javascript.


Exemples

HTTP script



UDP Datagrams

var dgram = require("dgram");

var server = dgram.createSocket("udp4");

server.on("message", function (msg, rinfo) {
  console.log("server got: " + msg + " from " +
    rinfo.address + ":" + rinfo.port);
});

server.on("listening", function () {
  var address = server.address();
  console.log("server listening " +
      address.address + ":" + address.port);
});

server.bind(41234);
// server listening 0.0.0.0:41234