Techbubbles

Why WebSockets?

 

WebSockets are required to develop the rich and real time web applications. WebSockets can securely enable the real-time web. Before explaining the need of WebSockets we see what current Web is and it’s limitations.

What is Current Web?

image

We have rich web applications in current web which does the bi-directional communication. HTTP is a request-reply protocol and it is hard to PUSH on top of this protocol. Current programming model use different techniques to get connect with server, one of them is Periodic Polling.

image

example: Browser uses XmlHttpRequest to periodically query the server.

image

In Long Polling Server holds the HTTP request until there is a data to return. Client Sends the data as soon as previous request completes.

The limitations with current programming model

  • Periodic polling technique uses high-latency.
  • Long polling programming model is unintuitive.

Many scale out and Bandwidth issues with current programming model and limited cross domain support too.

What All WebSockets about is?

WebSockets is a new interoperable technology still undergoing standardization.

  • It is full duplex bidirectional socket.
  • You can program against using a browser and JavaScript API.
  • WebSockets runs over SSL
  • Designed for high performance – it is a light weight messaging protocol, it requires low bandwidth and latency.
  • Important thing is it is designed to broad reach.
  • WebSockets also has the built-in capability to make cross-domain calls.

What Applications can get benefit from WebSockets?

It supports

  • Rich web applications
  • Real-time applications and services(stock tickers and monitoring systems)
  • Beyond browser – Windows 8 and mobile
  • Online games

WebSockets are in

  •   Windows 8
  •   Internet Explorer 10
  •   .NET 4.5

How it works?

The secret source for WebSockets protocol is HTTP handshake which enables the socket connection. When a client sends an HTTP request to WebSockets server, it contains the some information in header which tells the server to establish connection over WebSockets. If Server is happy to accepts the request and it then sends the HTTP response back to client and switches the protocol and starts the communication.

Once the handshake is complete client and server communicates over WebSockets using HTTP connection. The Message communication is in either binary or UTF8 format.


Share this post :


Related Posts:

%d bloggers like this: