0% found this document useful (0 votes)
26 views

Application Protocol - Web Socket

hiiiiiiiiiiiiiiiiii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Application Protocol - Web Socket

hiiiiiiiiiiiiiiiiii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

WebSocket

Introduction

• The Web becomes more and more

• Necessity of evolution to a platform for real-time data


exchange.
• Web Socket technology is the fundamental.
Web Sockets – Technology

• Websocket is a protocol providing communications


channels over a single TCP connection.
• Bidirectional
• Full-duplex
• Permanent TCP connections 4oo times less overhead ⅓
of latency.
• Standardized in HTML5 by W3C and IETF protects
investments
• Single TCP port salves 50% server ressources
• Its only relationship to HTTP is that its handshake is
interpreted by HTTP servers as an Upgrade request.
Web Sockets – Technology

• What else?
• Designed for interactive Web Applications
• Open for all kind of stationary and mobile browser
based and native apps.
• Not just a protocol, but a new paradigm
Request/Response Real-Time Comm.
Web Sockets – Concept

The Concept:
• Framework vs. Client/Server
• 3rd Party Engines and Servers
• Message Routing, Stream, Send, Broadcast, Events,
Channels
• Tokens and Plug-ins
• Listeners and Apps
• Filters and Encryption
Web Sockets

• Works when:
• server and/or client need to send data often
• browser support for WebSocket can be relied upon or
fallbacks can be used

• Falls short when:


• fallbacks can't be relied upon
Typical WebSocket architecture
How WebSocket Work?

• WebSocket provide a persistent connection between a


client and server that both parties can use to start
sending data at any time.
• The client establishes a WebSocket connection through
a process.
• Here is a simplified example of the initial request
headers.
How WebSocket Work?

• If the server supports the WebSocket protocol, it agrees


to the upgrade and communicates this through
an Upgrade header in the response.
• handshake is complete the initial HTTP connection is
replaced by a WebSocket connection.
• Websockets can transfer as much data as you like
without incurring the overhead associated with
traditional HTTP requests.
• Send messages in both directions simultaneously
Web Sockets API

• Very simple API:


• WebSocket - constructor that opens a connection to
server.
• onopen - event handler that fires when connection has
been established.
• onmessage - event handler that fires when receiving
data.
• onerror - event handler that fires when there is an error.
• onclose - event handler that fires when the server is
closing the connection.
• send - send data to server.
• close - close socket.
WebSocket Frames

• Have a few header bytes


• Text or binary data
• Frames are masked from client to server
Websocket can improve Web application development and execution

• WebSocket is part of HTML5 and EE7 Technologies.


• It is designed to make two-way, full duplex, long lived
communications between two web applications.
• WebSocket is efficient to use and easy to develop.
• It can be used as a replacement for http polling and http
long polling solutions.
• The WebSocket protocol, which assumes TCP/IP or
TCP/IP-like capabilities underneath it, is defined in RFC
6455.
• WebSocket pre-reqs.
• Servlet 3.1 capabilities to run inside a web server.
Why WebSocket? WebSocket is about…

• Performance
• WebSocket makes real-time communication much more
efficient.
• Simplicity
• WebSocket makes communication between a client and
server over the web much simpler.
• Standards
• WebSocket is an underlying network protocol that enables
you to build other standard protocols on top of it.
• HTML5
• WebSocket is part of an effort to provide advanced
capabilities to HTML5 applications in order to compete with
other platforms.
Advantages and Disadvantages WebSocket

Advantages:
• Supports Duplex communication
• Faster than HTTP
• Increased Client and Server Communication Efficiency
• Replacement of HTTP
• Uses TCP

Disadvantages:
• Browser must be fully HTML5 compliant
• Takes over the communications protocol between the client
and the server for a particular connection.
Applications of Websockets

• Social feeds
• Multiplayer games
• Collaborative editing/coding
• Click stream data

Example real-world uses:


• real-time chat application
• event-based in-page analytics
• more things
Future of Websocket

• New Dimension of Online-Collaboration


• New Level of online-Entertainment
• New opportunity for online Education
• New social Participation and Contribution
Socket vs Websocket

• WebSocket typically run from browsers connecting to


Application Server over a protocol similar to HTTP that
runs over TCP/IP. So they are primarily for Web
Applications that require a permanent connection to its
server.

• Sockets are more powerful and generic. They run


over TCP/IP but they are not restricted to browsers
or HTTP protocol. They could be used to implement any
kind of communication.

You might also like