Brian "Beej" Hall writes free programming guides on network programming, C, Unix IPC, and networking concepts.
Commenters call his network programming guide a classic. They recommend it as approachable yet deep, and as a top pick for learning networking.
I also like writing code in C both professionally and for personal projects.
One thing I LOVE about C is the offline documentation for standard libraries. Beej’s guide to network programming is amazing but also reproducible with “man socket” and then wandering down the rabbit hole. (Ref: https://beej.us/guide/bgnet/html/split/)
C++, the sprawling beast that it is, you have no choice but to consult some web page to get decent documentation. The same goes for Rust (Please let me know if I am wrong here, I have not used Rust in several years).
Maybe it’s just a personal quirk, but when programming I love to shut off Wi-Fi and focus on whatever it is I want to get done. It is not always feasible of course, but it is definitely my preferred way to work. And C is the most amenable language to being offline.
For a few years, I found myself continuously appreciating Go's design and models more and more. Right now, a bit bored of working in the same paradigm for a decade, I've been trying to find new approaches but find myself rather trapped - as after a novel exploration, it turns out the current approach really does seem to work better.
Go's whole concurrency model of Communicating Sequential Processes is cool, although seems to be the aspect I question the most. Erlang's Actor Model does seem a bit superior and Go can introduce footguns at points, but I've yet to really investigate the alternatives as much as I'd like.
Also, Beej's guide to network programming https://beej.us/guide/bgnet/html/ mentioned in the beginning really is quite fantastic.
This might be a bit extreme but if you really want to learn bottom-up I would suggest nand2tetris https://www.nand2tetris.org/
It's not about networking but it's a good way to understand the picture from electrons wiggling to a basic computer. It involves all the layers below Linux basically and a little bit of overlap. I'm not sure how much it will help in your network programming goals but it's not that hard to do and helped me a lot with fundamentals and knowing which parts of a system are responsible for what.
For more direct help I believe Beej's guide to network programming is greatly recommended https://beej.us/guide/bgnet/
I have to point this one out from his guide to C: https://beej.us/guide/bgc/html/split/hello-world.html
> Before we go on, why would I even begin to bother pointing out that a pound sign is called an octothorpe? The answer is simple: I think the word octothorpe is so excellently funny, I have to gratuitously spread its name around whenever I get the opportunity. Octothorpe. Octothorpe, octothorpe, octothorpe.
I can't find it right now but somewhere in the guide in a different chapter, he randomly inserts "Octothorpe"... good comedy. I think this kind of writing is exceedingly rare and immensely enjoyable.
I think Beej's Guide to Network Programming is IMO hands down the best resource I've come across:
https://beej.us/guide/bgnet/
It also doubles as a very great introduction to C, if that something you're interested in. It's funny because both C and socket level programming are often a barrier, or at least they were for me. It's an attestant to the quality of Beej's guide that he introduces both simultaneously, and makes it very approachable.
This is one of those sources that helped me disproportionately grow as a programmer in a short period of time.
Wanted to bump this. It's the book I recommend when someone asks, "How can I learn networking".
My next favorite is the Top-Down book everyone above mentions. I like that it starts with loading a web page, instead of bits on a wire. And they have pcap files so you don't even need a lab.
The Stevens book is the standard text for programmers writing network code.
Beej's Guide (https://beej.us/guide/bgnet/) Is how I learned.
By the time you get here, you'll know enough to know which book to read next.