Asosiy/Lug'at/WebSockets (Full-Duplex Real-Time Communication)
networking

WebSockets (Full-Duplex Real-Time Communication)

A computer communications protocol providing full-duplex communication channels over a single TCP connection.

Sodda Hayotiy O'xshatish

"HTTP is like sending letters back and forth; WebSockets is an open telephone line where both parties can talk continuously."

Qanday ishlaydi va Nega kerak?

Unlike HTTP request-response cycles, WebSockets keep an open socket channel, allowing the server to push updates instantly without polling overhead.

Amaliy Kod Ko'rinishi

typescript
const socket = new WebSocket("wss://thegogetters.uz/api/messages/stream");

socket.onmessage = (event) => {
  const message = JSON.parse(event.data);
  console.log("Yangi xabar:", message);
};

Asosiy Xulosalar

Essential for instant messaging, collaborative canvas, and financial tickers
Ultra-low latency frame overhead (2-10 bytes)
Complementary to Server-Sent Events (SSE) for unidirectional streams

Bog'liq Atamalar