
See how socket.io delivers real-time browser-server communication over web sockets and tcp, unlike Ajax, and why open connections power instant messaging.
Get a clear roadmap of the socket.io v4 course, from web sockets fundamentals to socket.io 101 and 201, with demos like a chat app and a multiplayer canvas game.
Explore why the course centers on socket io in 2023 and how it compares to native web sockets, highlighting low latency, bidirectional, event-based communication, and fallbacks.
Explore the pre-socketio foundations, from native JavaScript and TCP/UDP basics to the WebSocket API, and understand how socket.io uses WebSockets with failover.
Discover the practical node and express workflow, from choosing editors like Visual Studio Code to using nodemon for hot reloads, and aligning versions and tools for websocket projects.
Explore how data packets travel via the tcp/ip stack—from physical cables to http—and how tcp offers reliable, ordered delivery while udp remains fast but unreliable for socket.io and http.
Explore the networking stack from application to physical layers, and compare http, tcp, and udp, then learn how Socket.IO and WebSockets enable persistent connections.
explore how web sockets connect a browser client to a node server using the WebSocket API, a precursor to Socket.IO.
Explore native websockets and the web socket API to establish a two-way, event-driven browser-to-server connection, then set up a node web socket server with ws.
Discover how a native web socket handshake upgrades http to ws, inspect headers, manage the connection with on headers and on connection, and exchange messages with ws send.
This intro outlines what to expect in the socket.io section, including why to use socket.io over websockets and the main object with emit and on.
Choose socket.io, built on engine.io, to handle real-time web apps with reconnection, long polling fallback, and multiplexing to manage multiple rooms and acknowledgments.
Master the basics of socket.io by wiring an express server and a public client, installing npm modules, and exchanging messages with emit and on for a chat app.
Avoid the common pitfall in SocketIO v4 by not registering listeners inside the connect handler; use two separate handlers to avoid duplicates on reconnect.
Build a basic Socket.IO chat client and server using Express, port 8001, and a public chat.html with DOM updates, emitting and broadcasting new messages to all connected clients.
Explore the socket.io server API and learn how to instantiate a server in multiple ways—from an http server or express to passing options—and understand the documentation structure.
Explore socket.io v4 server options and their sane defaults, including the default path '/socket.io', the transports order (polling then WebSocket), and the impact of serve client and cors.
Master socket io v4 basics by building a server with io, using server emit, on, and connect, and exploring namespaces and the main namespace for broadcasting events.
Learn how the client API uses io to connect to a socket server, pass a url and options, and exchange events with socket.emit and socket.on within the main namespace.
Set up the Socket.IO 201 workspace, organize folders for namespaces and rooms, and a Slack clone, and scaffold express and public assets to build a featureful chat app.
Explore how namespaces and rooms organize a socket.io server, using a bucket-like hierarchy from server to namespaces to rooms. See simple and complex app patterns to prep documentation and implementation.
Learn how socket.io v4 manages asynchronous multi-client chat with namespaces and rooms, using a step-by-step client–server flow from join to chat history, in vanilla JS and Node.js.
Lay out a basic slack-style chat app using express and socket.io, create a server on port 9000, wire namespaces, handle client connections, and emit a welcome message for sanity checks.
Populate namespaces from the server using the ns list event, then update the DOM to display wiki, mozilla, and linux namespaces via socket.io and web sockets.
Use ES6 class syntax to build namespace and room classes with constructors (id, name, image, endpoint) and a rooms array, implement add room and clear history, and export with module.exports.
Update the DOM to display a namespace's rooms by clicking namespaces, rendering the corresponding rooms in the room list using client-side script.js and event listeners.
Learn how to modularize socket.io namespace joining with a dedicated join ns function, manage dynamic namespace population on reconnect, and enhance ux with optional last namespace storage.
Explore socket.io namespaces and multiplexing, dividing a single connection into default and admin namespaces with independent event handlers. Understand that namespaces are server-governed, and clients only request joining.
Explore how namespaces in socket io v4 separate main and admin traffic, using a single connection to emit to specific namespaces.
Explore server-side rooms in socket.io v4: join and leave rooms, broadcast with io.to and socket.to, and emit events to specific rooms within a namespace.
Connect to multiple namespaces in a dynamic Socket.IO setup and join three new namespaces, then update the dom with namespace and room data.
Explore real-time updates with socket.io and websockets by using namespaces and rooms, pushing changes from the server to clients instead of HTTP fetches, and updating the DOM efficiently.
Implement real-time namespace updates with socket.io v4 by wiring an express route to modify namespaces and emit an ns change event to clients, while handling reconnects and avoiding duplicate listeners.
Move namespace sockets outside flow and index them by ns id, then guard listener creation to prevent duplicates. This enables reliable reconnections and scalable websockets in a chat app.
Enable client-side room joining in socket.io v4 by attaching click listeners to rooms, emitting join room with namespace ID and room name, and preparing to fetch history.
Learn to implement acknowledgments in socket.io v4, using fetchSockets to count users in a room, and update history and UI through join/leave logic and callback responses.
Learn to replace callbacks with emit with ACK in SocketIO v4.6.0, using async/await to capture server acknowledgement; auto join the first room when a namespace loads.
Learn how to emit new messages to a socket.io v4 room over websockets by handling a namespace selection, submitting messages, and broadcasting to room members.
Utilize Socket.IO v4 and websockets to load room history in Slack, build dynamic message HTML, and render messages in the DOM while handling join room and namespace data.
Explore passing data on socket connections using query parameters and the io options, and implement secure credentials via the auth option to protect usernames and passwords during handshake.
Watch a project demo that builds a multiplayer Agar.io inspired game using socket.io v4 with websockets, exploring login options, a leaderboard, and lean server design.
Plan a real-time game strategy by detailing 30–60 fps frame updates, heavy bidirectional traffic, and a server authoritative model, while the client renders and minimizes bandwidth, with server handling collisions.
Build a clean Express and socket.io skeleton, then organize app with separate Express and socket main modules, exporting app and io from servers and unifying them in index.js for maintainability.
Set up the DOM for a socket.io game by creating UI and socket scripts, wiring bootstrap modals, and configuring the canvas to fill the window with login and name forms.
Clean up the last two UI pieces, wire the start game flow, and reveal the score and leaderboard. Separate UI, socket, and canvas code via an init function.
Initialize a player orb on a 2d canvas at a random position and render it with arc, fill, and stroke, while mouse movement keeps the orb centered and world moving.
Learn to make a canvas-based player follow the mouse with a mousemove listener, compute direction via atan2, and render via requestAnimationFrame that centers the viewport using translate.
Create server-hosted non-player orbs using socket.io and emit them to clients via an init event. Each orb has a random color, lock x/y, and a radius, drawn on the canvas.
Explore server-side collision handling, lean 30 fps networking with a player class containing player data and config, sharing color, name, and lock X/Y across clients while keeping per-player data private.
Design and implement the player system in socket main by creating player config and player data, then configure global settings for orbs, speed, zoom, and world width and height.
Refactor the init flow to improve performance by using an acknowledgement callback to return orbs, moving init from connect to a start game trigger, and tracking players on the server.
Program bidirectional real-time gameplay by sending player data from server to clients and back every 33 milliseconds, using socket rooms for the game, init events, and a 30 fps tick.
practice drawing server-sent player data on the client canvas by syncing a players array each tick, and render each player with its radius and color using canvas context.
Send the client's x and y vectors to the server via a talk event every 33 milliseconds, enabling the server to compute and broadcast each player's position to all clients.
Learn to clamp the game viewport to the player's server-synced position using socket.io v4 with websockets, and make errors loud to avoid silent failures amid async updates.
Explore collision testing for a socket.io game, applying an axis-aligned bounding box test before circle overlap to detect orb collisions and handling player collisions with score, radius, and zoom updates.
Implement and test orb and player collision logic in a Socket.IO v4 game, updating bounds, handling orb swaps with an orb switch event, and syncing client states in real time.
Implement and display the leaderboard by emitting update events on collisions, computing a score-based leaderboard from players, updating the dom, and handling empty objects for absorbed players.
Explore the disconnect event in socket.io v4, log the disconnection reason, and remove the player with the matching socket ID from the players array to update the leaderboard.
Build a socket.io v4 project that monitors cpu load and memory usage. Learn to connect a React frontend with a node program, with heartbeat and offline handling.
Learn how to scale socket.io with horizontal and vertical techniques, using multiple servers and adapters, including the cluster adapter, while handling sticky sessions and long polling.
Set up perf load with a node client and server, install socket.io client, and scaffold a React frontend to stream local performance data over socket.io using the cluster adapter.
Understand the architecture of a socket.io v4 with websockets, including a primary and worker cluster, node clients sending perf data, and React client listening, scaling via adapters and sticky sessions.
Kick off the node client to capture local performance data with the OS module, including CPU load, memory, uptime, and CPU info, for sending to the socket server.
Compute real-time cpu load by averaging per-core times across user, nice, system, and idle, sample every 100 milliseconds, and return a percent of cpu to the socket server.
Learn how the node cluster module scales socket.io by spawning multiple worker processes that share a single port, enabling better processor utilization and session continuity for websocket connections.
Implement the cluster module and cluster adapter to run Socket.IO across a Node.js cluster, coordinating primary and workers via sticky sessions and IPC.
Connect a react client to a cluster driven socket.io server, configure CORS and origin, and test the live connection across ports 3000 and 3001.
Connect the node client to the socket server by wiring socket.io with IO, test the connection, and refactor emits into a socketMain module that exports a function receiving IO.
Fetch the node client mac address via the os network interfaces, selecting a non-internal mac to uniquely identify machines when sending performance data at 1-second intervals to the socket server.
Implement a socket.io v4 client to emit performance data every second, attach the mac address, and use handshake auth tokens to route node and react clients into rooms.
Learn to build a UI with Create React App, review the file structure from index.js to App.js, and establish a testable socket connection within the src folder.
Learn basic React component architecture with an app containing widgets for CPU, memory, and info, updated as data comes in via a socket data stream and a widgets array.
Explore two ways to connect a React app to a Socket.IO server: a simple shared socket and a centralized, scalable pattern for large codebases, with auth tokens.
Connect a socket server to a React client to stream perf data, then build a widget-based component structure with cpu, mem, and info subcomponents.
Establish a socket connection, receive performance data every second, convert it with object.values into an array, and map to widgets by passing data and using Mac address as the key.
Reorganize the UI with bootstrap scaffolding, move files into utilities, update imports, and add widget.css, canvas load animation, and uptime visuals for cpu and mem.
Draws a CPU load arc on a canvas using two circles, with a gray inner circle and a colored outer arc that reflects load percentage and changes color by thresholds.
Build a memory widget by rendering a canvas-based memory usage circle in React, displaying total and free memory in gigabytes and updating with memory usage percentages.
Learn how to detect disconnects with an is alive check and disconnect event in socket.io v4, and update performance data with the machine mac address to surface offline status.
Debug a nasty React and Socket.IO bug across multiple workers where strict mode duplicates listeners; use a local perf data cache updated every second with setInterval to stabilize widgets.
Explore the socket.io v4 admin ui, a front-end tool that connects via websockets to monitor clients, transports, rooms, and server activity, demonstrated with an agar.io clone and an express setup.
Websockets are one of the coolest api's to ever hit the web. They allow the browser real-time communication, bridging one of the last gaps in both human and web-based communication. Socket io is the king library that uses websockets under the hood. There's a good chance if you're reading this, you've heard about socketio. Maybe even done a tutorial on it. But how far did you get? In my experience, the vast majority of the material on the web goes no farther than a quick-start, instant chat app. You don't learn how anything works, never look at the docs, and are stuck at the end wondering what to do now. Is that all socketio can do? The remaining shred of material is waaay over everyone's head. The fact that the websocket API was standardized in 2011 and most developers still don't know how to use it is evidence of the gap.
This course is meant to alleviate that! It is not a quick start guide to socket IO. There are loads of those all over the Internet. You should definitely look elsewhere if you are wanting a 10 minute intro to the 3-4 things you need to know to make something quick. On the other hand, if you are looking to really learn one of the most awesome JavaScript libraries in socket io, you should stick around. Like Express and other JavaScript/Node pieces, it's getting passed over in the wave to learn just enough to get to the term "full-stack developer." My main goal is to help you figure out how to go from being a good developer to a great developer. Understanding... not just knowing a few methods... of socketio is part of that! It even transcends the browser and node with implementations in most other languages, and even mobile/React Native. This means as you grow, you have the power of sockets without having to learn more than the socket io library.
I first used socketIO in 2013 for a tiny company directory app. I've been following since and have been frustrated that it hasn't gotten more mainstream notice because it opens the way for so many improvements to existing applications and obvious groundwork for new ones. Let's change that :) Prepare to for a detailed look at socketio and websockets and start going real-time.
Sections:
Introduction - course overview, github link, and the state of socketio and websockets
Before SocketIO... - TCP, network sockets, & a native websockets app
Socket.IO-101 - Why you'd want to use socketio (instead of just websockets), and how it works (simple chat app)
Socket.IO-201 - Making the chat app into a slack clone with namespaces and rooms
Project - real-time canvas game (agar.io-clone)
Project - Real-time performance data (uses React, Cluster, and the Cluster Module. Rotated Redis out until the new module is stable)
Supplemental - HTTP (for those in need of a review)
LEGACY - version 2 - Socket.IO-101
LEGACY - version 2 - Socket.IO-201
LEGACY - multi-player canvas game
LEGACY - Advanced Project
I hope to add sections for a streaming videos/socket.io-stream app, as well as a React Native app.