Server_Communication_Lecture_Notes
Server_Communication_Lecture_Notes
REST API:
REST ka full form hai Representational State Transfer.
CRUD operations (Create, Read, Update, Delete) ko HTTP methods ke zariye map
karta hai:
GET: Data retrieve karna.
POST: Naya data create karna.
PUT: Existing data update karna.
DELETE: Data delete karna.
Example:
GET /photos/ (Photos ki collection).
GET /photos/12345 (Specific photo resource).
WebSockets:
HTML5 WebSockets: Full-duplex communication (Dono taraf ek waqt par data send aur
receive karna).
Example code:
```
let socket = new WebSocket("ws://example.com/socketserver");
socket.onopen = () => socket.send(JSON.stringify({ type: "subscribe", channel:
"updates" }));
socket.onmessage = (event) => console.log(JSON.parse(event.data));
```
GraphQL:
Facebook ka protocol jo REST ke mukable ek flexible option hai.
Schema: Server resources ke properties define karta hai.
Ek query se multiple resources fetch kiye ja sakte hain.