I'd like to know how does Node handle connections. I mean: when I run...
node myserver.js
... and I make a request, what does Node do?
I've made a test. I have a server running with socket.io. I open two tabs in my browser which stablishes WebSockets connections. I check the threads (ps -eLf) and I get always the same 6 threads running:
node 12837 12518 12837 1 6 22:29 pts/0 00:01:10 node /usr/local/lib/node_modules/node-dev/wrapper.js prueba1.js
node 12837 12518 12838 0 6 22:29 pts/0 00:00:00 node /usr/local/lib/node_modules/node-dev/wrapper.js prueba1.js
node 12837 12518 12839 0 6 22:29 pts/0 00:00:14 node /usr/local/lib/node_modules/node-dev/wrapper.js prueba1.js
node 12837 12518 12840 0 6 22:29 pts/0 00:00:14 node /usr/local/lib/node_modules/node-dev/wrapper.js prueba1.js
node 12837 12518 12841 0 6 22:29 pts/0 00:00:14 node /usr/local/lib/node_modules/node-dev/wrapper.js prueba1.js
node 12837 12518 12842 0 6 22:29 pts/0 00:00:14 node /usr/local/lib/node_modules/node-dev/wrapper.js prueba1.js
I'm asking this because I'm trying to understand what does the blocking code actually blocks.
If you need to understand how asynchronous IO in node works on low level I suggest to read following documentation: