5
5
Class: CE2
Roll no: 19
IOT ASSIGNMENT 5
What is WebSocket?
Real-time, bidirectional communication: Both server and client can send messages
whenever needed without initiating a request.
Efficient for frequent, small updates: Low overhead compared to HTTP because it
eliminates the need to send headers with every request.
Low latency: Keeps the connection alive, making it highly responsive.
REST-Based Communication API
REST is an architectural style for designing networked applications. It works over HTTP and
uses stateless communication. Each request from the client to the server is independent,
meaning no persistent connection is required.
1. Client Sends HTTP Request: The client sends an HTTP request to the server,
usually using methods like GET, POST, PUT, or DELETE.
2. Server Processes Request: The server processes the request and sends an HTTP
response with the requested data or status.
3. Stateless Communication: Each request is independent of previous requests. There is
no persistent connection or session.
Stateless: Each request from the client contains all the information needed to process
it. No need to maintain session data between requests.
Well-suited for CRUD operations: It is ideal for situations where the client and
server communicate by exchanging resources (like JSON or XML data).
Easy to implement: REST is simple, with clear methods (GET, POST, PUT, DELETE),
and relies on HTTP, which is widely supported.
REST is suitable for applications that involve CRUD operations (Create, Read,
Update, Delete), such as web services for accessing and managing data.
It is best for simple, non-real-time interactions.
Both WebSocket and REST have their own strengths, and the choice depends on the specific
use case—whether the application requires real-time interaction or can work well with the
traditional request-response model.