Serving the Web Like It's 1999 (But Also 2026)
You know what the modern web is missing? Green phosphor.
We spend so much time building responsive React apps, optimizing Largest Contentful Paint, and debating Tailwind vs. CSS-in-JS that we forget the simple joy of a raw TCP connection.
So, naturally, I decided to make my blog accessible via Telnet.
Because why just read a blog in a browser when you can telnet www.buggycoder.com 2323 and feel like you're hacking into a mainframe in a sci-fi movie?
It's unencrypted plaintext, yeah. It opens my server port to resource exhaustion issues, sure.
Enter the Sniffer
It turns out, you can just... look at the TCP data to determine the protocol.
When a browser connects, it immediately starts shouting GET / HTTP/1.1.
When a Telnet client connects, it either sends some negotiation bytes (starting with 0xFF) or... it says nothing at all (we'll get to that).
I used AI to write a simple "Sniffer" in Node.js that intercepts the raw TCP socket before passing it to the HTTP server or the Telnet handler.
Here is the "magic" logic:
export function detectProtocol(data: Buffer): 'http' | 'telnet' {
// 1. Is it a Telnet command? (Starts with IAC byte 0xFF)
if (data[0] === 0xff) return 'telnet';
// 2. Fallback to HTTP for everything else!
return 'http';
}
It's surprisingly effective! I wrapped this in a net.createServer that just "peeks" at the first chunk of data.
The "Silent Client" Problem
Of course, it wasn't that simple. (Is it ever?)
I ran into a bug where I would telnet localhost 2323 and... the cursor would just blink. Forever.
Why? Because unlike browsers, Telnet clients don't always speak first.
If I just connect and wait, my server is sitting there waiting for data to "sniff", and the client is sitting there waiting for a welcome banner. It was a classic Mexican Standoff.
The Fix: A timeout. I added a SNIFF_TIMEOUT (3 seconds).
// If you don't say anything in 3 seconds,
// I'm assuming you're a human on a terminal.
setTimeout(() => {
if (!handled) {
initializeTelnetSession(socket);
}
}, 3000);
The Result
It’s completely unnecessary, over-engineered, and I absolutely love it.
Go ahead, try it out:
telnet www.buggycoder.com 2323
You may have to resize your terminal once to have the content adapt to the window size. Will fix this some other time.
Don't Panic.