In this section, we will take a look at WebSockets, a protocol, which is finding wider adoption in modern applications.
WebSocket is a bi-directional communication protocol based on TCP. Websocket allows the client (generally a browser) to open a TCP channel with the server and the server can continuously send data to the client. The client need not poll the server for data. This allows for real time message transfer between the server and the client over TCP port number 80. Since the standard port 80 is used, it can overcome the firewall rules which block other non-standard ports.
To establish a websocket connection, the client and server, exchange a handshake request which is similar to a HTTP request. (The request response headers consist of an Upgrade attribute, which could be interpreted by servers which serve HTTP requests).
Reference use cases:
Websockets are generally used in chat applications, applications which provide live stock updates etc.