Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 3.95 KB

File metadata and controls

48 lines (33 loc) · 3.95 KB

Socket.IO is a JavaScript library that enables real-time, bi-directional communication between web clients (browsers) and servers. It provides a way for web applications to exchange data continuously, allowing for a more dynamic and interactive user experience.

Here's a breakdown of key features of Socket.IO:

  • Real-time communication: Data is exchanged between clients and servers instantly, without the need for constant page refreshes. This is ideal for applications like chat, collaborative editing, or live dashboards.
  • Bi-directional: Both clients and servers can initiate communication and send/receive data. This allows for a more responsive and interactive experience compared to traditional request-response patterns.
  • Event-based: Communication happens through events. Clients and servers listen for specific events and react accordingly when those events are triggered. This makes the code more organized and easier to manage.
  • Multiple transports: Socket.IO can use different transport mechanisms like WebSockets (preferred for speed) or HTTP long-polling (fallback for older browsers) to ensure broad compatibility.

Here are some common use cases for Socket.IO:

  • Chat applications: Real-time messaging between users without page refreshes.
  • Collaborative editing: Multiple users can edit a document simultaneously and see changes reflected instantly.
  • Live dashboards: Displaying real-time data updates on dashboards or applications.
  • Social networking: Real-time notifications, updates, and live feeds.
  • Multiplayer games: Enabling real-time interaction between players in online games.

Overall, Socket.IO is a valuable tool for building web applications that require real-time data exchange and interactivity.

Socket IO

Web Socket is a communication protocol that provides full-duplex communication channels over a single TCP connection. It allows real-time, bi-directional communication between a client and a server, enabling them to send messages to each other without the need for continuous polling.

Socket.IO is a JavaScript library that enables real-time, bidirectional and event-based communication between the browser and the server. It builds on top of the Web Socket protocol and provides additional features such as automatic reconnection, multiplexing, and support for different transports (e.g., Web Socket, AJAX long polling, etc.).

Web Socket:

  • Web Socket is a communication protocol that provides full-duplex communication channels over a single TCP connection.
  • It allows real-time, bi-directional communication between a client and a server.
  • Web Socket eliminates the need for continuous polling, enabling efficient and instant data transfer.

Socket.IO:

  • Socket.IO is a JavaScript library that enables real-time, bidirectional, and event-based communication between the browser and the server.

  • It is built on top of the Web Socket protocol, leveraging its capabilities for real-time communication.

  • Socket.IO provides additional features such as automatic reconnection, multiplexing, and support for different transports.

  • It offers a seamless and reliable way to establish real-time communication channels between clients and servers.

  • Socket.IO is widely used in applications that require real-time updates, such as chat applications, collaborative tools, and live streaming platforms.

  • Each socket connected to server have an id

  • io.emit is event for entire circuit , socket.emit is specific to socket

  • other methodes are socket.broadcast.emit in which the event is emitted for other socket except himeself

  • socket.to().emit() to is socket id of other client

  • socket.join(roomName) to join people in room then every event trigger for room is handle by every socket, we can use socket.to(roomName) to send message to room

  • every socket is in room with room name as socket.id

  • socket.io provide bi-directional communication channel between a client and a server.