• Bi-directional communication in Real-time over TCP connection
  • Unique connection to reduce latency issues from long-polling
  • Both client and server can stream handshake messages independently and simultaneously over TCP
  • A web socket handler keeps an open connection with active users
  • Server responds with HTTP status 101 Switching protocols
  • Header Sec-web Socket-Accept with a processed string of client-key (given by the client)
    • This helps ensure secure/authenticated key

Masking

  • Masking helps distinguish web socket data from HTTP requests
    • Helps stop caching from proxies

Fragmentation

  • Fragmentation helps prevents exceeding of buffer limitations and stops overwhelming connections from large messages
    • Prevents buffer overflow
  • FIN( Final) bit tells us if the existing frame is the final fragment of the message
    • Set to 0 for all but last frames of the message
    • Set to ‘1’ for final frame to signal final fragment of message to receiver

HTTP Polling

  • Makes it so the client keeps sending, requests
  • Server sends a blank response when nothing to report
  • Leads to a lot of requests being made
    • Causes HTTP overhead!

HTTP Long Polling

  • A client needs to connect periodically, making long polling more resource-intensive
  • Client waits with a hanging GET request to a server and waits until timeout
  • If the request times out, the client will send another hanging GET request