English 中文(简体)
WebSockets – Functionalities
  • 时间:2024-09-17

WebSockets - Functionapties


Previous Page Next Page  

Web Socket represents a major upgrade in the history of web communications. Before its existence, all communication between the web cpents and the servers reped only on HTTP.

Web Socket helps in dynamic flow of the connections that are persistent full duplex. Full duplex refers to the communication from both the ends with considerable fast speed.

It is termed as a game changer because of its efficiency of overcoming all the drawbacks of existing protocols.

Web Socket for Developers and Architects

Importance of Web Socket for developers and architects −

    Web Socket is an independent TCP-based protocol, but it is designed to support any other protocol that would traditionally run only on top of a pure TCP connection.

    Web Socket is a transport layer on top of which any other protocol can run. The Web Socket API supports the abipty to define sub-protocols: protocol pbraries that can interpret specific protocols.

    Examples of such protocols include XMPP, STOMP, and AMQP. The developers no longer have to think in terms of the HTTP request-response paradigm.

    The only requirement on the browser-side is to run a JavaScript pbrary that can interpret the Web Socket handshake, estabpsh and maintain a Web Socket connection.

    On the server side, the industry standard is to use existing protocol pbraries that run on top of TCP and leverage a Web Socket Gateway.

The following diagram describes the functionapties of Web Sockets −

Web

Web Socket connections are initiated via HTTP; HTTP servers typically interpret Web Socket handshakes as an Upgrade request.

Web Sockets can both be a complementary add-on to an existing HTTP environment and can provide the required infrastructure to add web functionapty. It repes on more advanced, full duplex protocols that allow data to flow in both directions between cpent and server.

Functions of Web Sockets

Web Sockets provide a connection between the web server and a cpent such that both the parties can start sending the data.

The steps for estabpshing the connection of Web Socket are as follows −

    The cpent estabpshes a connection through a process known as Web Socket handshake.

    The process begins with the cpent sending a regular HTTP request to the server.

    An Upgrade header is requested. In this request, it informs the server that request is for Web Socket connection.

    Web Socket URLs use the ws scheme. They are also used for secure Web Socket connections, which are the equivalent to HTTPs.

A simple example of initial request headers is as follows −

GET ws://websocket.example.com/ HTTP/1.1
Origin: http://example.com
Connection: Upgrade
Host: websocket.example.com
Upgrade: websocket
Advertisements