Menu
Node.js ContohBerikut ialah pelaksanaan lengkap hello world sebagai pelayan HTTP dalam Node.js:
var http = require('http');http.createServer( function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); }).listen(8000);console.log('Pelayan dijalankan di http://localhost:8000/');
Kod berikut ialah pelayan TCP ringkas yang mendengar pada port 7000 kemudian echo 'hai' semasa bersambung:
var net = require('net');net.createServer( function (stream) { stream.write('hai\r\n'); stream.on( 'end', function () { stream.end('selamat tinggal\r\n'); } ); stream.pipe(stream); }).listen(7000);
Menu
Node.js ContohBerkaitan
Node.jsRujukan
WikiPedia: Node.js http://github.com/joyent/libuv http://github.com/ry/node/blob/master/AUTHORS http://mashable.com/2011/03/10/node-js/ http://www.readwriteweb.com/hack/2011/01/wait-what... http://www.sdtimes.com/NODE_JS_PUSHES_JAVASCRIPT_T... http://nodejs.org/ http://nodejs.org http://npmjs.org/ http://www.theregister.co.uk/2011/03/01/the_rise_a... https://id.loc.gov/authorities/names/n2013024269