Search code examples
websocketsocket.ioengine.io

What is the relationship between ws engine.io and socket.io


This question basically makes it sound like the node library Socket.io uses the library engine.io which uses ws.

What role do each of these play given that each one can independantly create a WebSocket connection?


Solution

  • Look at Introducing Socket.IO 1.0 - New engine to see why they made Engine.IO.

    Engine.IO has all the browser hacks and different things for compatibility, and has modularised the Socket.IO codebase.

    You are correct that Socket.IO uses Enginge.IO which uses ws.

    • Engine.IO takes care of the connection and browser hacks.
    • ws is used when upgrading to websockets.

    Socket.IO handles:

    • setup/connection to http.Server. (but engine.io has this as well)
    • list of clients
    • rooms
    • namespaces
    • decoding/encoding of Socket.IO packet format