
Beej's Guide to Network Programming - nnain
http://beej.us/guide/bgnet/
======
Uptrenda
Oh boy, this one brings me back. I can't tell you how many times I read this
guide back in the day. Beej was the bomb when it came to network programming.
Another great resource for network programming is
[http://www.madwizard.org/programming/tutorials/netcpp/](http://www.madwizard.org/programming/tutorials/netcpp/)
which is aimed more at Windows users. Failing that, there's the classic Unix
Network Programming Vol 1 and 2 which gives a good outline of what to expect.

As it turns out, there are some really subtle aspects of network programming
and these guides tend to cover them well.

~~~
dwc
Same here. Mostly I would just read man pages and write code, but every so
often there's something that only works if you know the proper incantation
(call ordering or whatever) and Beej almost always had the right answer, with
sample code.

------
jshmrsn
While we're sharing network programming guides, the Gaffer on Games guide on
multiplayer networking is another great read
[http://gafferongames.com/networking-for-game-
programmers/](http://gafferongames.com/networking-for-game-programmers/)

~~~
josephg
For game network programming, the Source Multiplayer Networking guide is a
fantastic high level write-up of how modern games use prediction to compensate
for latency:

[https://developer.valvesoftware.com/wiki/Source_Multiplayer_...](https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking)

------
diggan
Haven't come across this before and it looks like a really valuable resource
and since it's licensed under Creative Commons, I took the freedom to rehost
it on IPFS here:
[https://ipfs.io/ipfs/QmeZJ6QQ4gztfrNDFHfBtBi4KGv6w87PcVKqqJK...](https://ipfs.io/ipfs/QmeZJ6QQ4gztfrNDFHfBtBi4KGv6w87PcVKqqJKuM8UWiS/)

Another question for all the folks here at HN, is there more resources like
this that would be considered as "definitive guide" as many mentioned, related
to networking or distributed systems?

~~~
marktangotango
I wouldn't call this a "definitive" guide. Because there's a lot that's not
covered. I mean it's great and helped me through the projects in a networking
course, but I had to look elsewhere for a lot of stuff like multi threading.

For similar content I think this is something we've lost with the modern
Internet. The web used to be full of people posting tutorials and how to's.
Seems like hobby and indie game dev generated a lot of this type of content. I
remember flipcode and gamedev.net had a lot of material on a lot of subjects
(including networking) in their article and tutorials sections. These are
probably archived somewhere. Edit ok look like it's been updated since 2004,
I'll have to read it again!

~~~
chatmasta
I'm not sure how you arrived at this conclusion. As someone who started
learning to code around 2004, I remember exactly what you are talking about.
There were tons of tutorial websites (I liked spoono, anyone remember that?),
tutorial aggregators (good-tutorials, pixel2life), and programming communities
(phpforums, neverside, sitepoint). I learned coding by following tutorials to
create an example project, then modifying features to my liking. It was nice,
but there was a lot to be desired, and if you ran into an esoteric bug you
pretty much had no option but to post to some random phpBB board or IRC
channel and hope for a response. StackOverflow and GitHub didn't even exist!

It seems that nowadays it's easier than ever to learn to code, with many
different resources and communities at the disposal of the newbie.
StackOverlow is amazing and 99% of the time you google some esoteric error
message you'll find a SO post; no need to post to forums or ask in IRC. GitHub
is full of open source projects, tutorials, and example code. If you prefer
learning with videos, there's tons of open source material. And in terms of
guides "like this," there are thousands of new posts every day across the
blogosphere by developers sharing their experience. Not to mention many old
pieces of content still exist, the OP being just one example.

I really think that access to educational technical content has exploded in
the past ten years, and I completely disagree with your conclusion that the
state of this content was any better in 2004 than it is now.

~~~
squarefoot
> you pretty much had no option but to post to some random phpBB board or IRC
> channel and hope for a response. StackOverflow and GitHub didn't even exist!

Usenet baby, Usenet. Still alive today although doomed beyond any optimistic
hope.

------
pvg
Comes up so often, we've practically run out of things to say about it.

[https://hn.algolia.com/?query=Beej's%20Guide%20to%20Network%...](https://hn.algolia.com/?query=Beej's%20Guide%20to%20Network%20Programming&sort=byDate&dateRange=all&type=story&storyText=false&prefix&page=0)

~~~
kuekerino
what happened 7 years ago? break of 3 years not being posted

~~~
pvg
We do not speak of the Greater Beej Occlusion.

------
trollied
It really is the definitive guide. I remember reading it when I was doing my
Computer Science degree back in 1996.

~~~
spapas82
Same for me but around 2003 :)

It was probably the best thing to read to quickly start learning sockets!

~~~
roansh
Same for me as well, around 2012 :)

~~~
geekodour
Same for me as well, around 2017.:)

~~~
Infinitesimus
Same here in 2012. It's quite amazing how many of us this guide has impacted

------
susam
This is a very entertaining guide on socket programming that I came across
about 10 years ago. An excerpt from the guide: Stream sockets are reliable
two-way connected communication streams. If you output two items into the
socket in the order "1, 2", they will arrive in the order "1, 2" at the
opposite end. They will also be error-free. I'm so certain, in fact, they will
be error-free, that I'm just going to put my fingers in my ears and chant la
la la la if anyone tries to claim otherwise.

Last year, I decided to read the recently published newer version of this
guide that describes how to write code that works for both IPv4 and IPv6.

An archive of examples and experimental code that I wrote while reading this
book: [https://github.com/susam/lab/tree/master/c/beej-guide-to-
net...](https://github.com/susam/lab/tree/master/c/beej-guide-to-network-
programming)

------
justin66
It's honestly kind of nice to have multiple sources treating the same material
a different way. This, Stevens' _UNIX Network Programming,_ and Kerrisk's _The
Linux Programming Interface_ are all a student should need to get started with
socket programming.

~~~
ryandrake
You beat me to the Richard Stevens book. Truly the comprehensive guide.
Everyone should have it on their shelf.

------
seiferteric
I remember reading through the original version around my first year as an
engineering student at Chico state around 2004. Only later did I realized that
this guide that I learned so much from was hosted on the Chico State
engineering servers! somehow I overlooked the URL. I followed the trail and
realized that Beej was an alumni from Chico as well and had some sort of group
(I forget the name). I emailed him to see if it was still active and he
responded but alas it was not. They were responsible for rigging up the the
soda machine in the computer science department to the network and I believe
you could check the current stock levels of the different soda types.

------
aaronmdjones
I recall reading this start to end, twice, around 2009. I read it again a few
years ago as it had been updated to include things like references to
libevent.

------
pietromenna
He also have other guides! This are old but gold guides! I learned C with his
guides and also learned network with this one.

------
nautical
I learnt a lot of things from this book . Its a really good to start . (Around
~2007 if I am not wrong )

------
annerajb
This reminds me of my networking class! I remember being provided Beej's Guide
and it being indespensable. Still 8 years later when I need to verify
something about networking I go look it up and make sure i am doing it right.

------
darasan
Brings back lots of memories - had it permanently open in my browser when I
wrote a P2P file transfer / messenger app for a project about 10 years ago.
Socket programming is so much fun :-)

------
a_t48
Beej's is great. Crack it open every time I have to work with network sockets
(on my third reliable UDP library now...).

------
rahed
I really liked Lincoln Stein's Network Programming with Perl. Excelent
examples and clearly explained from the basics.

------
n3x10e8
I am finding this guide very helpful. Are there guides for other Linux
concepts just like this guide.

------
m0narch
I just used this guide for my Network Programming class last fall. I love it
so much.

------
chrismoos
This is classic -- one of the main reasons I started programming in C.

------
d0m
I read it over and over again 15 years ago, great resource.

------
known
Nostalgia

~~~
mamaniscalco
On one of the previous comments argued that he would not could call Beej's
work "a definitive guide". Fair enough but "classic" is very accurate.

I don't know why your response is graying but I hear you ... nostalgia! I miss
the time when this classic was magic.

