0% found this document useful (0 votes)
5 views5 pages

Web Socket

WebSockets are a communication protocol that enables real-time, bidirectional data transfer between clients and servers, enhancing web applications' interactivity. They were created to address the limitations of traditional HTTP by providing a persistent connection that reduces network overhead and server load. While WebSockets offer advantages like real-time communication and scalability, they also face challenges such as browser compatibility and potential server resource consumption.

Uploaded by

miragelife2020
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)
5 views5 pages

Web Socket

WebSockets are a communication protocol that enables real-time, bidirectional data transfer between clients and servers, enhancing web applications' interactivity. They were created to address the limitations of traditional HTTP by providing a persistent connection that reduces network overhead and server load. While WebSockets offer advantages like real-time communication and scalability, they also face challenges such as browser compatibility and potential server resource consumption.

Uploaded by

miragelife2020
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/ 5

Lesson:

Web Socket
Topics Covered
Introduction
Transmission Modes
Web Sockets
Why were web sockets created
Working of Web Sockets
Advantages of Web Sockets
Disadvantages of web sockets.
WebSockets is like a superpower for web developers! They are a technology that allows real-time
communication between web browsers and servers, enabling developers to create highly interactive web
applications. With WebSockets, you can build applications that respond instantly to user actions, display live
data feeds, and much more. Think of WebSockets as a magical portal that connects your web browser to the
server, allowing you to communicate in real time without having to constantly refresh the page. It's an
exciting technology that is revolutionizing how we interact with the web, and once you start using it, you'll
wonder how you ever built web applications without it!


Transmission Modes.

Before understanding web sockets you need to understand the transmission modes.

Transmission modes refer to the direction of data flow between two communication devices in a computer
network. 

There are three types of transmission modes


Simplex: In simplex mode, data can only flow in one direction. One device is the sender and the other is the
receiver. The receiver can only receive data, and the sender can only transmit data. Examples of simplex
mode communication include a radio broadcast or a television transmission
Half-Duplex: In half-duplex mode, data can flow in both directions, but not simultaneously. Only one device
can transmit data at a time, while the other device receives it. The devices take turns transmitting and
receiving data. Examples of half-duplex mode communication include a walkie-talkie or a two-way radio
Full-Duplex: In full-duplex mode, data can flow in both directions simultaneously. Both devices can
transmit and receive data at the same time, without waiting for each other. Examples of full-duplex mode
communication include a telephone call or a video conference.


In computer networks, transmission modes are important because they determine the type of
communication that can take place between two devices. Choosing the appropriate transmission mode is
crucial for ensuring efficient and effective communication.

Web Sockets.

A WebSocket is a communication protocol that enables full-duplex and bidirectional data transfer between a
client and a server over the internet. Unlike the traditional HTTP protocol, which is unidirectional and stateless,
WebSockets enable real-time communication, allowing data to flow back and forth between the server and
the client in real time.

Full Stack Web Development


Once a WebSocket connection is established, it is kept open until either the client or the server terminates it.
This means that the connection remains "stateful", allowing data to be transmitted in real-time between the
two endpoints.

When the connection is closed, either by the client or the server, the connection is terminated from both ends.
This means that both the client and the server can initiate the closure of the connection.

WebSockets have become an important tool in internet architecture, as they enable real-time communication
between clients and servers, and they are used in various applications, such as online gaming, chat
applications, and financial trading systems, to name a few. Their ability to provide real-time, bi-directional
communication has made them an essential component of modern web development.

Why were web sockets created?

The traditional HTTP protocol used in web development is designed for client-server communication, where the
client sends a request to the server and the server responds with a static or dynamic resource. However, this
communication is unidirectional and lacks real-time interaction between the client and server.

With the increasing demand for real-time web applications, there was a need for a new technology that
allowed for bidirectional, real-time communication between the client and server. This is where WebSockets
come in.

WebSockets provide a persistent, low-latency connection between the client and server, allowing for real-time,
bidirectional communication. They use a message-based format to send and receive data and can transmit
data in either text or binary format. This makes it possible to create real-time web applications such as chat
applications, multiplayer games, and collaborative editing tools.

Before WebSockets, real-time communication in web applications was achieved using techniques such as
polling or long-polling, where the client would repeatedly send requests to the server to check for new data.
This approach was inefficient and put a strain on server resources. With WebSockets, the connection between
the client and server is kept open, eliminating the need for repeated requests and reducing server load.

Thus, WebSockets were developed to address the need for bidirectional, real-time communication in web
applications, and provide a more efficient and effective way to create real-time web applications.

Full Stack Web Development


Working of Web Sockets.

WebSockets allow for real-time, bidirectional communication between a client and a server. The WebSocket
protocol basically follows the below-mentioned steps

The client sends a WebSocket handshake request to the server over an HTTP or HTTPS connection. This
handshake request contains the URL of the WebSocket server and a set of headers that describe the
WebSocket protocol and other parameters
If the server accepts the WebSocket handshake request, it responds with a WebSocket handshake response.
This response includes a set of headers that describe the WebSocket protocol and other parameters. Once
the client receives this response, the WebSocket connection is established
Once the WebSocket connection is established, the client and server can send and receive data in real-time.
The client can send data to the server using a WebSocket send() method, and the server can send data to
the client using a WebSocket send() method
The WebSocket connection remains open until either the client or server closes the connection. Once the
connection is closed, the WebSocket object is disposed of and can no longer be used.

The WebSocket protocol uses a message-based format to send and receive data. Messages can be in text or
binary format, and can be of any length. The WebSocket protocol also includes mechanisms for error handling,
authentication, and compression.

Advantages of Web Sockets.

WebSockets provide a number of advantages over traditional HTTP-based communication protocols. Here are
some of the key advantages of WebSockets:

Full Stack Web Development


Real-time communication: WebSockets provide a persistent, low-latency connection between the client and
server, allowing for real-time, bidirectional communication. This makes it possible to create real-time web
applications such as chat applications, multiplayer games, and collaborative editing tools
Reduced network overhead: WebSockets use a persistent connection, eliminating the need for repeated
requests and reducing network overhead. This makes WebSockets more efficient than traditional HTTP-
based communication protocols such as polling or long-polling
Scalability: WebSockets allow for multiple connections to be open at the same time, allowing for a high
degree of scalability. This is especially important for applications that require real-time, bidirectional
communication between many clients and servers
Reduced server load: WebSockets reduce the server load by eliminating the need for repeated requests and
reducing network overhead. This makes WebSockets more efficient than traditional HTTP-based
communication protocols, reducing server load and improving application performance
Flexibility: WebSockets can transmit data in either text or binary format, making them highly flexible and
adaptable to a wide range of applications
Security: WebSockets use the same security protocols as HTTP, such as SSL/TLS, to ensure secure
communication between the client and server.

Disadvantages of web sockets.

Although WebSockets provide many advantages over traditional HTTP-based communication protocols, they
also have some disadvantages. Here are some of the key disadvantages of WebSockets
Browser compatibility: Although WebSockets are supported by most modern browsers, there are still some
older browsers that do not support WebSockets. This can make it difficult to create applications that are
compatible with all browsers
Firewall and proxy issues: Some firewalls and proxies may block WebSocket traffic, making it difficult to
establish WebSocket connections between clients and servers. This can limit the usability and accessibility
of WebSockets
Server resource utilization: WebSockets can consume more server resources than traditional HTTP-based
communication protocols, especially if many clients are connected simultaneously. This can impact server
performance and scalability.

Full Stack Web Development

You might also like