Web developmentLesson 4 of 4 in the course HTTP and web servers

WebSocket Protocol: Handshakes, Framing, Security, and Deployment

5 flashcards · 5 quiz questions · 5 match pairs · 4 fill-in sentences · English

Lesson progress
0 / 5

Your progress is kept in this browser only.Sign up to save it

Summary

WebSocket provides a persistent, two-way communication channel between a client and a server. This lesson introduces how it differs from ordinary HTTP exchanges and how an HTTP handshake establishes a WebSocket connection.

WebSocket is a communications protocol that carries messages in both directions over one TCP connection. Once connected, the client and server can each send data at any time. This is called full-duplex communication.

All flashcards

What is WebSocket?
A protocol that carries messages in both directions over one TCP connection.
How does a typical HTTP/1.1 WebSocket handshake work?
The client sends a GET request asking to upgrade protocols; if accepted, the server responds with status 101.
What is a fragmented WebSocket message?
One message split across a starting frame and one or more continuation frames.
Why are client-to-server WebSocket frames masked?
The protocol requires masking with a four-byte key; masking is not encryption.
What do Sec-WebSocket-Key and Sec-WebSocket-Accept provide?
They help prevent a caching proxy from replaying an earlier conversation, but do not authenticate users.

Quiz questions

  1. What does full-duplex communication allow a WebSocket client and server to do?Answer: Send data independently in either direction over the same connection.
  2. Which status code indicates a successful protocol switch in a typical HTTP/1.1 WebSocket handshake?Answer: 101, Switching Protocols.
  3. Why should a WebSocket server validate the request's Origin header?Answer: To help prevent cross-site WebSocket hijacking.
  4. Which WebSocket frames must be masked?Answer: Frames sent from a client to a server.
  5. When was the WebSocket protocol finalized as RFC 6455?Answer: December 2011.

Based on the Wikipedia article WebSocket, licensed CC BY-SA 4.0. Adapted into a summary, flashcards and quizzes.

All Web development lessons