Alt Protokoller, Uzantılar ve Sıkıştırma
Uygulama alt protokollerini müzakere ederek ve ileti başına sıkıştırma gibi uzantıları etkinleştirerek WebSocket protokolünü daha derinlemesine öğrenin.
Alt Protokoller, Uzantılar ve Sıkıştırma, CoddyKit'te ücretsiz bir WebSockets & Realtime Systems Programming dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, WebSockets & Realtime Systems Programming öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. WebSockets & Realtime Systems Programming kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Beyond the Basics
The raw WebSocket protocol only moves bytes. Two negotiation mechanisms let you layer meaning and efficiency on top: subprotocols and extensions.
What Is a Subprotocol
A subprotocol is an agreed application-level message format, like a contract for what the bytes mean. Examples include wamp, mqtt, and graphql-ws.
Requesting a Subprotocol
The client lists desired subprotocols in a handshake header.
Sec-WebSocket-Protocol: graphql-ws, jsonServer Selection
The server picks one subprotocol it supports and echoes it back. If none match, it omits the header and only the base protocol applies.
Sec-WebSocket-Protocol: graphql-wsSubprotocols in the Browser
Pass an array of subprotocol names as the second argument when opening the socket.
const ws = new WebSocket('wss://api.example.com', ['graphql-ws', 'json']);
console.log(ws.protocol); // the one the server choseWhat Is an Extension
An extension changes how frames are transmitted at the protocol level, transparent to your application logic. The most common is per-message compression.
Negotiating Extensions
Extensions are negotiated in the handshake too, via their own header.
Sec-WebSocket-Extensions: permessage-deflatePer-Message Deflate
permessage-deflate compresses each message with DEFLATE before sending. It cuts bandwidth for text-heavy payloads at the cost of CPU.
When Compression Helps
Compression wins for large, repetitive JSON or text. For tiny or already-compressed payloads (images, binary), it adds overhead without benefit and can be disabled.
Subprotocol vs Extension
Keep them straight:
- Subprotocol: meaning of the messages (application layer)
- Extension: how frames are transported (protocol layer)
Practical Notes
Both are negotiated only during the handshake and cannot change afterward. Always verify ws.protocol client-side so your code parses messages with the agreed format.
Quick Check
Test your protocol knowledge.
Recap
You explored advanced WebSocket negotiation:
- Subprotocols agree on message format via
Sec-WebSocket-Protocol - Extensions change frame transport via
Sec-WebSocket-Extensions permessage-deflatecompresses text payloads- Both are fixed at handshake time
You now understand the negotiation layer of WebSockets.
Sıkça Sorulan Sorular
“Alt Protokoller, Uzantılar ve Sıkıştırma” dersi ücretsiz mi?
Evet — “Alt Protokoller, Uzantılar ve Sıkıştırma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve WebSockets & Realtime Systems Programming kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. WebSockets & Realtime Systems Programming kursu toplamda 4 dersten oluşur.
“Alt Protokoller, Uzantılar ve Sıkıştırma” dersinde ne öğreneceğim?
Uygulama alt protokollerini müzakere ederek ve ileti başına sıkıştırma gibi uzantıları etkinleştirerek WebSocket protokolünü daha derinlemesine öğrenin. WebSockets & Realtime Systems Programming ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
WebSockets & Realtime Systems Programming öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te WebSockets & Realtime Systems Programming, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Alt Protokoller, Uzantılar ve Sıkıştırma” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu WebSockets & Realtime Systems Programming dersinde kod yazıp çalıştırabilir miyim?
Evet. Her WebSockets & Realtime Systems Programming dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- WebSocket El Sıkışma Sürecini Anlama
- WebSocket Veri Çerçeveleme ve İletiler
- Bağlantı Yaşam Döngüsü ve Durumları
- Alt Protokoller, Uzantılar ve Sıkıştırma