Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Socket.IO multithread?

I have a socket.io server which listens to sockets:

io.sockets.on('connection', function(socket){
    socket.on('myEvent', function(data){
        socket.emit('eventReceived', { status: 1 });
    });
});

Is this code working in multithread? if two clients will emit the myEvent event, it will work at the same time for both clients? or it will be handled one after the other?

Many thanks!

like image 302
udidu Avatar asked May 04 '26 19:05

udidu


1 Answers

Nothing in Node.js is multithreaded including any packages available through npm. There is an experimental cluster module available in the core

http://nodejs.org/docs/v0.10.2/api/cluster.html

like image 114
deltanovember Avatar answered May 07 '26 11:05

deltanovember