-
Notifications
You must be signed in to change notification settings - Fork 7
Socket.io
ALL edited this page Nov 23, 2019
·
1 revision
- WebSocket is a computer communications protocol
- Designed to work over HTTP ports 80 and 443 as well as to support HTTP proxies and intermediaries
- The WebSocket protocol enables interaction between a web browser (or other client application) and a web server with lower overhead than half-duplex alternatives such as HTTP polling, facilitating real-time data transfer from and to the server
- A standardized way for the server to send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open
- The communications are done over TCP port number 80 (or 443 in the case of TLS-encrypted connections), which is of benefit for those environments which block non-web Internet connections using a firewall
- To establish a WebSocket connection, the client sends a WebSocket handshake request, for which the server returns a WebSocket handshake response
- Socket.IO enables real-time bidirectional event-based communication
- Enables real-time, bi-directional communication between web clients and servers
- It has two parts:
- Client-side library that runs in the browser
- Server-side library for node.js
- Sockets work based on events. There are some reserved events, which can be accessed using the socket object on the server side.
- These are
- Connect
- Message
- Disconnect
- Reconnect
- Ping
- Join and
- Leave
- The client-side socket object also provides us with some reserved events, which are −
- Connect
- Connect_error
- Connect_timeout
- Reconnect, etc
- These are
- Key features of WebSocket :
- It is the communication Protocol which provides bidirectional communication between the Client and the Server over a TCP connection
- WebSocket helps in real-time communication between the Client and the web server.
- This protocol helps in transforming to cross-platform in a real time world between the server and the client.
- This also enables the business around the world for real-time web application to enhance and to increase the feasibility.
- The major advantage it stands over an HTTP connection that it provides full duplex communication.
- Key features of Socket.IO:
- It is a library which enables real-time and full duplex communication between the Client and the Web servers
- It uses the WebSocket protocol to provide the interface
- It helps in broadcasting to multiple sockets at a time and handles the connection transparently.
- It works on all platform, server or device ensuring the equality, reliability, and speed.
- It automatically upgrades the requirement to WebSocket if needed.
- It is a custom real-time transport protocol implementation on top of other protocols.
- It requires both libraries to be used Client side as well as a server-side library.
- IO works on work-based events. there are some reserved events which can be accessed using the Socket on server side like Connect, message, Disconnect, Ping and Reconnect.
- There are some Client based reserved events like Connect, connect- error, connect-timeout and Reconnect etc.