WebSockets and Web Pages Two Way Communication
Suppose that you have to design a web application (i.e. stock exchange) which should be designed in the way that the client should be updated instantly with any change submitted by other clients, and also you have to implement this design using ASP.NET (or other web apps technologies).
As you know that HTTP protocol is stateless protocol based on request/response using non-permanent connection with server which is not longer than your request/response time, there is no problem to implement this type of applications using windows forms and WCF full duplex, but the challenge here is to implement it using web pages technology.
So what is the scenario that you can use to implement this design using ASP.NET Pages?
- Periodical checking the server side for any updates from other clients (also the same will be done by other clients) which will lead into hitting server performance with direct proportion with transactions number, also this is not corresponding with real time apps like stock exchange due to the delay of periodical checking and other issues, So this scenario is not practical scenario for this type of apps.
- The above scenario will leading you to think about something that let server side updating the subscribed clients with any change between each other, but again the nature of HTTP protocol will not help you to do that whilst the request direction always from client to server, some developers resolved this issue with some tricky way by letting the connection opened between server and client, and to do that your server side should be in continuous response until you ending your session with server. This scenario will resolve our issue concerned with HTTP protocol; but still complex to be implemented and hard to maintain.
- Another scenario is to use the new invented technique “WebSockets” standardized by W3C and supported mainly by latest version of browsers like chrome and fire fox, also there is a Lab by Microsoft(part of HTML 5 Labs) to be supported in IE, WebSockets is a technique for two-way communication over one (TCP) socket, using WebSockets is the best scenario to implement Stock Change app based on web technology and also it will be the future of this type of apps, this solution will save a lot of time and work around to introduce real-time apps through web browsers.
What is WebSockets?
WebSockets is a technology providing for bi-directional, full-duplex communications channels, over a single Transmission Control Protocol (TCP) socket, it is designed to be implemented in web browsers and web servers, The WebSocket API is being standardized by the W3C, and the WebSocket protocol is being standardized by the IETF
Good WebSockets links