node.js - Is nodeJs event-driven? -


in "professional nodejs" found sentence "this project (nodejs) not other server-side javascript platforms i/o primitives event-driven , there no way around it." but, know, nodejs event-driven , streams in nodejs event-driven. can explain sentence?

node.js asynchronous event driven framework. in following "hello world" example, many connections can handled concurrently. upon each connection callback fired, if there no work done node sleeping.

const http = require('http');  const hostname = '127.0.0.1'; const port = 1337;  http.createserver((req, res) => {   res.writehead(200, { 'content-type': 'text/plain' });   res.end('hello world\n'); }).listen(port, hostname, () => {   console.log(`server running @ http://${hostname}:${port}/`); }); 

this in contrast today's more common concurrency model os threads employed. thread-based networking relatively inefficient , difficult use. furthermore, users of node free worries of dead-locking process—there no locks. no function in node directly performs i/o, process never blocks.

for detail go source.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -