Skip to content
Advertisement

What is a simple way to use websockets in Node.js WITHOUT a library?

I want a simple socket connection, where the server should tell the client the total amount of connections (whenever a connection happens), and the client should update the DOM. I feel like socket.io or any other library is too full featured for such a simple reason. Any idea how to do this without libraries?

Advertisement

Answer

Node.js documentation shows a very good example how to communicate using Sockets without libraries: https://nodejs.org/api/http.html#http_event_upgrade

Socket.io is not too ‘full featured’. It’s quite minimalistic and makes everything works with much less pain. I really recommend you trying it.

Advertisement