Beej's Guide to Network Programming
Beej's Guide to Network Programming
Stay updated with breaking news from Beej Guide To Network Programming. Get real-time updates on events, politics, business, and more. Visit us for reliable news and exclusive interviews.
There are many ways for computers to talk to other computers. A commonly used approach is a Remote Procedure Call, or an RPC. An RPC allows for the abstraction of calling another computer’s procedure as if it were a local one with all of the transmission and communication taken care of. Let’s say we’re writing some math program on a single computer and we have some procedure or function that handles checking if a number is prime.
If you play around with your computer long enough, you will inevitably encounter C. Maybe you use dwm and need to write your config file…in C. Or you want to work on an optimized Python module…in C. Or a kernel driver, or Apache, or… well, you get the picture. The picture is even bigger than that, though.
WebSocket (WS) connections are pretty neat. I’ve gotten to play around with them before, both for personal and professional projects, but my view has mostly been at a high level and concerned mainly with the things that I can build on top of them. I haven’t spent much time digging through the protocol. I thought it would be pretty interesting to build a toy WS server from scratch. Like many other projects, I find building a toy system to be such a good way to learn more, and I’ll be talking about this toy WS server (and some of those things I learned) in the rest of the post.