When I was a kid, socket programming felt like a huge thing to me, like unlocking the next level of programming. "Imagine if I could get 2 separate computers to talk to each other!" But it felt impenetrable, and used lots of weird and confusing C tricks.
Your guide demystified the whole subject and put it in plain language that teenage me could understand, and with it, I was able to build my first network-based "hello world". It was a magical feeling to see those messages delivered across the network. Thanks Beej!
Same exact story - I was perhaps 9 or 10 and got to Beej's work on sockets. It was one of the more accessible things available to me (or known to me). I remember reading Stevens books next.
So interesting that so many people have the same experience
Beej: thanks a million ! I learnt all about sockets and select() from your guide back at uni over 20 years ago. I was trying to make an autonomous model helicopter for my 3rd year project, fuel oil powered, with a scarily large rotor diameter… so I made this single threaded emergency stop daemon that listened to a few sockets, including the big red button, which would interrupt the test joystick data and write out some engine-off and neutral collective pitch commands instead.
And yes, it worked in a real emergency ! the heli didn’t have any rotors afterwards but we still had our heads.
Thanks for your hard work! When I discovered your guides ages ago I already had digested a good part of the famous text by W. Richard Stevens, but being my copy a very poorly translated edition (I did read English back then, but the imported book would cost a small fortune), I later had to check some things on your guides for consistency, so they turned out very useful anyway.
Hey! Thank you so much for your networking guide! It's my go to reference for socket programming and it is the documentation that I pointed my students to when I was giving a networking course :).
Not directly related but while you're here: you should _really_ add Marcus Rediker's Villains of all nations to your Pirates reading list. I highly recommend it! It's the best pirates' book ever =).
I just pulled it up to refresh my knowledge for a project and it was different. The thing that sticks out the most being different is that the code boxes are highlighted. My first time reading, it was standard grey boxes similar to some other guide (IPC guide I just read was still grey boxes!). Great work! It's the best reference!
I just happened to reread the guide a couple of weeks ago. I hadn't done c socket programming in maybe a few years, and the guide refreshed my memory really well.
Correct. The title was editorilized. And not enough with that, it's not even true that the guide has been updated, not for years according to the author himself in the currently top-voted comment.
So in a way this ended up to be perfect clickbait. But nobody seems to complain because despite not having been updated the guide seems to recall many fond memories by the commenters.
Highlighting users does not work on HN, I think the recommendation is to send an email.
beej! Wow! I read your guide in undergrad (many years ago, on the recommendation of a prof) and self-taught myself how networks work a year before my dedicated class on the subject. Your work truly inspired me then and I still fondly recall your work and advocate for others to read it.
I've yet to break into this one (I've seen it recommended so many times on HN). I'm no network engineer, but networking is a lot of fun for me and I enjoy learning about how it all works. High Performance Browser Networking[0] was one of my favorite books on this topic. Very approachable, even to complete beginner. I suspect that Beej's guide is a bit more low level and I look forward to that!
I think HPBN and Beej's guide are perfect companions to each other. They've been the most useful resources on my journey to learn more about networking.
Indeed, this guide is very informative and easy to digest. It's practically required reading for anyone taking CS 6200: Introduction to Operating Systems [1] in Georgia Tech's Online Master of Science Computer Science program.
Thank you, Beej. Looking forward to reading this again today.
The weirdest thing just happened. I was on https://beej.us/guide/ and I removed the last part of the URL to make it only https://beej.us and I pressed enter. This took me to cnet.com. I have never been on cnet.com before. I have no idea how this happened. Does anyone have a clue? I'm using Firefox if that matters. Did a web server somewhere get hit by a cosmic ray or is beej's server infected by something? This is super weird. When I try to do it again it just takes me to beej's site as expected.
I couldn't reproduce, but I note the background image changes on reloads. Perhaps beej is hotlinking, and one of the images is based on cnet, who redirected to themselves?
Beej's Networking guide is probably the funniest software book I've ever read. There are parts in there that actually get me to laugh aloud. All while being a fantastic intro to sockets.
Couldn't recommend this more. Free online, plus you can purchase the paperback now.
Man, this is so cool -- an old-school programming resource that isn't encrusted with ads and trackers, just the information you want in HTML format. Kenton Lee's X programming guide was another such resource, but sadly that appears to have been eaten by the internet Langoliers.
No, not necessarily. You can use these APIs directly from many different languages. For example, Python has 'socket'[1], Ruby has 'socket'[2], Julia has 'Sockets'[3], PHP has 'socket_*'[4].
It uses the gcc compiler so C, or C++ can be applicable.
That being said, this book teaches network programming from the ground up so I would recommend understanding how to compile and output C code, then go through the book.
If you run into keywords, or syntax that you are not familiar with, just google it, and then keep working through the examples.
Mind you, the key takeaways from this book are not how to network practice IN C, but general practices. This knowledge can be applied to plenty of other languages such as Rust.
My favorite C programming book was Expert C Programming by Peter van der Linden, mainly for the method of reading any C declaration and for teaching me the difference between libc calls vs syscalls. There's also a book called Modern C by Jens Gustedt from 2020 that I have and is more beginner friendly.
The way I learned C is I printed out the Beej's guide client/server code and walked around staring at it until it made sense. (That and compiling/running it and looking up functions in the man pages.)
Expert C Programming is brilliantly written. I recently bought another copy because I lost mine; I don’t actually need it, but it’s a fun read regardless.
I'll most definitely be checking out your guide! Thank you so much for your contributions in the community :) Will the latest revision of your Networking Guide be available on print any time soon? I'd love to buy a copy.
Has anyone actually even tried the K&R book in the past couple of decades and not run into issues like the assumption of unbuffered shell output? You get like one or two chapters in and things are already behaving outside of how they did when that book was written in the 1980s. It's a classic, yes, but I don't recommend it to anyone outside of people writing code in C89 for vintage systems... Yet the amount of suggestions I see from people who haven't actually learned C from scratch since the 1990s to read that particular title is high enough that I can't do anything but scratch my head over it. Tons has changed over thirty plus years.
If you're looking for something up to date I'd recommend this:
I taught myself C from K&R 2, and a platform-specific (Amiga!) book, back when I was a teenager. In three decades, not much has really changed with the core language.
While the core language has stayed the same the tooling and development environment has changed quite a lot. Proper modern compiler flags (-Wall etc) for example would be a huge help to new learners and for best practices, but k&r isn't mentioning these. I still think it's a good book but if you throw it at someone new to this they're going to be wondering why what they are writing isn't behaving as expected.
Not necessarily but it does help. These tutorials focus mainly on the Berkeley Sockets API which can be exposed as-is (or with slight modification) to many languages beyond just C/C++.
It is useful mainly if you have to do some netprog in C, and secondarily if you have to deal with language bindings that do a 1:1 mapping to the BSD socket API.
In other words, you will know when you need it - unless you forget it exists (note: bookmarking it might be a good idea, cause you could remember something like this exists but "what was the name again?").
I did update it for IPv6, but that was several years ago.
So I'm not sure which update the OP is referring to.
Appreciate the kind words, though!