Web Sockets

by Jamie Zawinski

Several of our systems require a simple websocket server. This is one. There are many like it but this is mine.

Web Sockets are basically a distributed whiteboard. Think of them as a realtime command-and-control IRC channel that you can access from Javascript.

But since this is the Stupidest Timeline, the received wisdom for how you spin up a WebSocket server involves installing libraries that will pull in 100k lines of code from whatever the singing-est dancing-est toolkit du jour is, and do you have time to audit that crap? I don't. All this just to let you burp out literally 20 lines of on-the-wire protocol.

Enter Net::WebSocket::Server, which gets my vote. It's tiny and very low level. The documentation was confusing and functional examples nonexistent. However, I eventually figured out how to make it go, and so now you can too: