Skip to content
Mina Samir
Back to projects

2026

Manual WebSocket Server

WebSocket protocol implementation built directly on Node.js TCP sockets to explore handshakes, frame parsing, connection lifecycle, and broadcast behavior.

Role
Backend Developer
Team
Engineering lab

Overview

An engineering lab that implements core WebSocket protocol behavior without a WebSocket framework.

Challenge

Understand WebSocket behavior below framework abstractions while handling connection lifecycle and protocol frames correctly.

Responsibilities

  • Implemented the HTTP upgrade handshake
  • Encoded and decoded WebSocket frames
  • Handled masking, extended payloads, fragmentation, ping/pong, and close frames
  • Tracked active connections and implemented broadcast

Solution

Built the upgrade handshake, frame codec, control frames, fragmentation handling, connection tracking, and broadcast directly on Node.js TCP sockets.

Architecture

A Node.js TCP server with explicit HTTP upgrade handling, frame parsing and encoding, connection state, heartbeat control frames, and broadcast.

Technical decisions and trade-offs

  • Used raw TCP sockets to expose protocol mechanics
  • Kept frame parsing explicit for learning and inspection
  • Handled control frames separately from fragmented data messages

Technologies

  • Node.js
  • JavaScript
  • TCP
  • WebSocket