Wiki
  • Introduction
  • Inspirations
  • Software
    • Systems Design
    • Tooling
    • npm
    • CLI
    • Programming Languages
    • Terminal
    • Shell Scripting
    • macOS
    • Networking
      • TCP
      • WebSockets
      • Web RTC
    • Web Development
      • React
      • HTML / CSS
    • Backups
    • Unix
    • Observability / Monitoring
    • SRE
    • Vim
  • Web Design
    • Inspirations
  • Project Management
    • Lean
  • Career
    • Job Hunting
  • Finances
    • Car Buying
  • Clothing
    • Material
    • Mid Layers and Jackets
    • Base Layers
    • Shoes
    • Socks
  • Productivity
    • Goals
    • Learning
    • Computer Usage
  • Well Being
    • Social Bonding
    • Gratitude
    • Health
      • Injury
      • Water Fluoridation
      • Vitamin D
      • Magnesium
      • Breathing
      • Vision
      • Anxiety
      • Hydration
      • Sleep
        • White Noise / Background Noise
        • Napping
        • Wakefulness
      • Nutrition
        • Intermittent Fasting
        • Alcohol
      • Exercise
        • When to exercise
      • Standing
      • Longevity
    • Learning
    • Laundry
    • Hygiene
      • Oral Hygiene
        • Buying a Toothbrush
        • Flossing
    • Raynaud’s
    • Skin Care
      • Face Care
      • Sun Protection
    • Hair
      • Pomade
    • Sore Feet
  • Ideas
    • Leveraging and Training our Brain's autopilot
    • Keys
    • Mental Models
  • Craft
    • Coffee
    • Parenting
    • Handywork
    • Cooking
    • Golf
      • Personal
  • Travel
    • Flying
    • Does wearing a hat keep you cooler in the heat?
  • Cryptocurrency
  • English
  • Miscellaneous
  • GTD
  • Quantum Computing
  • German
  • German Culture
  • Mechanical Keyboards
  • Mosquitoes
Powered by GitBook
On this page
  • Notes
  • Links
  1. Software
  2. Networking

WebSockets

PreviousTCPNextWeb RTC

Last updated 3 years ago

Notes

  • With long polling, the client opens an HTTP connection to the server which keeps it open until sending response. Whenever the server actually has new data it sends the response ()

  • ws:. This is the new URL schema for WebSocket connections. There is also wss: for secure WebSocket connection the same way https: is used for secure HTTP connections. ()

  • Leverages TCP connections

  • "full-duplex" connection: Both parties can send messages and receive at the same time

  • Event-based

  • Short-coming is that it's only 1-to-1 -- doesn't natively support many clients talking to each other

  • WebRTC is alternative geared towards browser-to-browser and audio/video

  • New tech that's up-and-coming: WebTransport

    • Basically a better version

    • Faster handshakes

    • Better reliability

  • Can send buffers, blobs, or strings

    • Send JSON by stringifying it

  • Convoluted handshake process, to ensure both parties are sure their using WebSockets requests ()

  • Has a method of streaming where multiple frams for a message come in separately, and the server decodes whether or not to concatenate them

    • Uses a FIN bit to tell if the message is still going or not (1 for finished)

  • There's a pinging/ponging mechanism, controlled by a frame's opcode

  • Handshake with HTTP, then the TCP connection is opened

Links

source
source
source
The WebSocket API (WebSockets) - Web APIs | MDN
Socket.IO
Berkeley sockets - Wikipedia