Developer Conference 2012
    MICROSOFT USER GROUP KOLKATA
Web Sockets – Building Real Time App for Web

Sankarsan Bose
26th May , 2012
The Real Time “Web”

 Real Time Web
 -   Real time information delivery
 -   Instant updates, searches
 -   Facebook, Twitter.. Etc.

 Technologies
 -   HTTP essentially is still stateless
 -   Technologies/Techniques we have to support the same are
      -   AJAX (XMLHttpRequest)
      -   Long Polling
      -   Comet


 Challenges
 -   Clients polling for data, ideally where server should broadcast
 -   Overhead of
      Multiple TCP connections
      Same/similar header data being transferred each time over the wire
      Customized ways to tracking or correlating requests and responses.
WebSockets - Introduction

 WebSockets

 -   WebSockets is a protocol for two-way communication between client and server
 -   Uses a single TCP connection.
 -   Takes away overhead of
      -    Multiple TCP connections
      -    Same/similar header data being transferred each time over the wire
      -    Customized ways to tracking or correlating requests and responses.

 -   Part of HTML5       initiative
 -   WebSocket Specs has
      -    Protocol Specification
      -    API Specification

 -   Supported by Google Chrome, Firefox,IE   10
 -   Server side support by Jetty,Node.js (Socket.io), IIS   8.0 (on Windows 8)
WebSockets with IIS 8.0 and IE10




Let’s go to the code…
WebSocket - API

            Client                                                        Server
          (Browser)
                      Establish Connection
                      var ws= new WebSocket("ws://www.websockets.org");

                      Connection Established

OnOpen event
fired                 Data Sent to Server

Send method           Data Sent from Server
called

OnMessage
event is fired        Close Connection


 Close method
 is called            Connection Closed



OnClose
Event is fired
WebSockets Protocol




      Client                                              Server
    (Browser)

          Send HTTP Request for protocol switch/upgrade




         - If server understands WebSocket protocol
                - It issues HTTP 101
                - There is a protocol switch
                - HTTP connection is no longer used
                - WebSocket connection takes over the
                   underlying TCP connection
References

- http://www.websocket.org/
- http://datatracker.ietf.org/doc/rfc6455/?include_text=1
- http://dev.w3.org/html5/websockets/
- http://www.paulbatum.com/2011/10/getting-to-know-
  systemnetwebsockets.html
- http://codingndesign.com/blog/?p=267
Thanks Everybody, For Your Time.
Happy Coding…..Enjoy Learning..
Speaker Details/Contact




- http://twitter.com/sankarsan
- http://sankarsan.wordpress.com
- http://codingndesign.com
- http://sankarsanbose.com
Dev con kolkata 2012   websockets

Dev con kolkata 2012 websockets

  • 1.
    Developer Conference 2012 MICROSOFT USER GROUP KOLKATA
  • 2.
    Web Sockets –Building Real Time App for Web Sankarsan Bose 26th May , 2012
  • 3.
    The Real Time“Web” Real Time Web - Real time information delivery - Instant updates, searches - Facebook, Twitter.. Etc. Technologies - HTTP essentially is still stateless - Technologies/Techniques we have to support the same are - AJAX (XMLHttpRequest) - Long Polling - Comet Challenges - Clients polling for data, ideally where server should broadcast - Overhead of Multiple TCP connections Same/similar header data being transferred each time over the wire Customized ways to tracking or correlating requests and responses.
  • 4.
    WebSockets - Introduction WebSockets - WebSockets is a protocol for two-way communication between client and server - Uses a single TCP connection. - Takes away overhead of - Multiple TCP connections - Same/similar header data being transferred each time over the wire - Customized ways to tracking or correlating requests and responses. - Part of HTML5 initiative - WebSocket Specs has - Protocol Specification - API Specification - Supported by Google Chrome, Firefox,IE 10 - Server side support by Jetty,Node.js (Socket.io), IIS 8.0 (on Windows 8)
  • 5.
    WebSockets with IIS8.0 and IE10 Let’s go to the code…
  • 6.
    WebSocket - API Client Server (Browser) Establish Connection var ws= new WebSocket("ws://www.websockets.org"); Connection Established OnOpen event fired Data Sent to Server Send method Data Sent from Server called OnMessage event is fired Close Connection Close method is called Connection Closed OnClose Event is fired
  • 7.
    WebSockets Protocol Client Server (Browser) Send HTTP Request for protocol switch/upgrade - If server understands WebSocket protocol - It issues HTTP 101 - There is a protocol switch - HTTP connection is no longer used - WebSocket connection takes over the underlying TCP connection
  • 8.
    References - http://www.websocket.org/ - http://datatracker.ietf.org/doc/rfc6455/?include_text=1 -http://dev.w3.org/html5/websockets/ - http://www.paulbatum.com/2011/10/getting-to-know- systemnetwebsockets.html - http://codingndesign.com/blog/?p=267
  • 9.
    Thanks Everybody, ForYour Time. Happy Coding…..Enjoy Learning..
  • 10.
    Speaker Details/Contact - http://twitter.com/sankarsan -http://sankarsan.wordpress.com - http://codingndesign.com - http://sankarsanbose.com