14 ms·
Beej's Guide to Network Programming
- kderbyma 3y agoBeej helped me get into programming back in 2004-5....what a legend!
- alberth 3y agoBeyond this being a fantastic document, I really appreciate it being offered as a single HTML page: https://beej.us/guide/bgnet/html/ https://beej.us/guide/bgnet/html/
- schaefer 3y agoAnd a physical print book.
- asdfkljvalkj 3y agoThe funny thing is at the time downloading that took like 5 minutes back in the day.
- d1n037 3y agoFunny I was just going over this again yesterday. Also didn't know he had one called Beej's Guide to Network Concepts[0], which has some really good explanations in it. [0] https://beej.us/guide/bgnet0/html/split/ https://beej.us/guide/bgnet0/html/split/
- zabzonk 3y agoit is what a great short guide should be. but i am sure dang will be posting a huge number of previous links.
- peter_l_downs 3y agoPosted a million times before, and should be posted a million times again in the future. This is one of the only reference books I've ever used, and it got me through my first real programming job. Wonderful text. Thank you, Beej!
- eep_social 3y agoThis is probably the best one: https://news.ycombinator.com/item?id=26100075 https://news.ycombinator.com/item?id=26100075
- gabagool 3y agoCould be wrong, but isn't this the same Guide?
- eep_social 3y agowhoops, best thread is what I was thinking.
- bdcravens 3y agoI think that's the point. They were talking about how many times it's been posted, so that's probably the best of those submissions.
- snarkypixel 3y agoThis guide was my bible when I was a kid. I learned not just network programming, but also C with it.
- CamperBob2 3y agoThat's how Andrej Karpathy's video lectures are shaping up for me... I'm learning a lot about not just neural networks, but Python and Pytorch. It's more or less magical when you find just the right conjugate match between tutorial material and your own learning style. I can see how Beej's Guide might do the same for someone new to both socket programming and C.
- b33j0r 3y agoMy nick has been Beej or b33j ever since starcraft or counterstrike 1.5. I will always bring up “but you know who the real beej is, right?” if the other person is a nerd.
- tomcam 3y agoNow maybe I have to change all my usernames to animats0r for the same reason
- deleted 3y ago[deleted]
- b33j0r 3y agoFunny enough I only got this joke on my second read. One of my uncles had a company with a name similar to your joke :D ADD probably. So, to me it was beej. But in reality, to the public [you can’t nickname yourself]. So it’s always been b33j0r. My friend who had the first dedicated server I encountered named me that because my name is Brian Jor—- Finding me has been trivial since I first AWP’d in a CAL-O match. This was before scoutznknives were more than merit badges.
- girvo 3y ago> counterstrike 1.5 I miss WON. Man my friends and I hated Steam when it came out...
- verandaguy 3y agoThis gets reposted on HN every few months or so, And I couldn't be happier, Beej's guide is a seminal read for anyone looking to get into net programming. Exposing as many newbies to it as possible helps strengthen the field.
- code_witch_sam 3y agolearned sockets with this like 20 years ago programming IRC fserve bots in C
- TallGuyShort 3y agoThere is a handful of people whose tabs I would instantly pick up were I to meet them somewhere because of the immense value I have gotten from their free work online, writing stuff, answering forum posts, etc. Beej possibly tops that list.
- vajrabum 3y agoAll Beej's guides are fantastic, but if you're interested in Network programming you could do way worse than follow this up with his guide to network concepts. https://beej.us/guide/bgnet0/ https://beej.us/guide/bgnet0/ If you search Algolia for Beej you'll see his material has been on hacker news numerous times.
- jamestimmins 3y agoIs this better as a preface to Network Programming or a suffix?
- vram22 3y agoYes, it seems reading about the concepts should be done first.
- sph 3y agoAnyone knows of a well-rounded guide that explains the structure of the Internet at large? I know everything listed in the one you linked, but I have a nebulous idea of how anything works after my packet exits my gateway. So, BGP, autonomous systems, peering agreements and other site-to-site routing protocols that keep the entire Internet infrastructure ticking along.
- capableweb 3y agoI don't know of any one resource that gives a overview of everything, I find that browsing Wikipedia for each topic gives a good overview of each topic though, with the overview being the "Internet Architecture" category: https://en.wikipedia.org/wiki/Category:Internet_architecture https://en.wikipedia.org/wiki/Category:Internet_architecture Some bookmarks I have regarding BGP and peering that dives into it a bit: - https://www.fortinet.com/resources/cyberglossary/bgp-border-gateway-protocol https://www.fortinet.com/resources/cyberglossary/bgp-border-... - https://aws.amazon.com/blogs/architecture/internet-routing-and-traffic-engineering/ https://aws.amazon.com/blogs/architecture/internet-routing-a... - https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bgp/configuration/xe-16/irg-xe-16-book/configuring-a-basic-bgp-network.html https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bg...
- ftxbro 3y ago> "The way I see it, it's the educators who hold all the power in the world. No, stop laughing and hear me out. A good instructor can, over the course of their career, create hundreds of millions or even billions of dollars of GDP. Let's say a teacher teaches 40 students a year for 30 years. And Each of those students goes on to work for 40 years. And, due to the quality of instruction, they earn $10,000 more per year than they would have otherwise. That's $480 million in extra revenue. From one good instructor." OK but providing value isn't the same as having power. It's almost the opposite thing.
- whimsicalism 3y agoWhat are you quoting?
- ftxbro 3y agoit's beej saying why he write guides
- jrumbut 3y ago> OK but providing value isn't the same as having power. Providing value is absolutely a way of having power. You change the world, that's power. Having power isn't the same as yielding benefit (for yourself).
- TeMPOraL 3y agoWhen people talk about having or not having power, they rarely mean magnitude alone. The more important component is control. Can you wield your power to achieve some specific goal of yours? Can you use this power to overall improve your life, and lives of those you care about? Can you use this power to protect yourself from someone else using their power to achieve something at your expense? Beej's teaching power only answers "Yes" to the first question here - and that's only if your goals have something to do with teaching or improving the world overall, somewhere, for some people.
- 3y ago
- deleted 3y ago[deleted]
- keyle 3y agoThere is also a C guide [1] which has a pretty interesting email policy... I’m generally available to help out with email questions so feel free to write in, but I can’t guarantee a response. I lead a pretty busy life and there are times when I just can’t answer a question you have. When that’s the case, I usually just delete the message. It’s nothing personal; I just won’t ever have the time to give the detailed answer you require. [...] [1] https://beej.us/guide/bgc/html/split/ https://beej.us/guide/bgc/html/split/
- mu53 3y agoI love this level of honesty. It is true, but people never say it
- ryandrake 3y agoI had a work colleague with a similarly refreshing Out-Of-Office E-mail autoresponder that included something like: "I'm on vacation. When I get back I'm not going to have time to read all my missed E-mails. So your mail is going to be ignored and deleted with the other 2,000 unread mails. If it's important, E-mail me again after I return on [date]." That's how you do it!
- keyle 3y agoThere is a massive caveat to this strategy "Email me again after I return". Tssk tssk. Big mistake. Always do the "If it's urgent, contact <someone else>" approach ;)
- ly3xqhl8g9 3y agoHere's a product (Gmail/Outlook add-on or so): have your own LLM trained over your public texts (articles, books, blog entries, READMEs, Hacker News comments, and so on), mark the emails you can't respond to with the "GPT" label which puts the mail in a queue and if you don't remove the label in 7 days or so, it sends a response with a polite intro "I didn't have the time to get to your email, but here's what I might think as a response".
- saboot 3y agoI'll ask here in case I can get help. I followed Beej's linked guide to transfer data over udp sometime ago, written in C on a Windows machine. I then compiled the code on Mac os x but could never get it to work properly. Tried all the Google suggestions at the time, posting this comment in case there's an obvious "oh did you set X?" tip from someone that has done a similar task.
- thrwawy74 3y agoI'm not saying Rust is the answer to all things, I'm saying I want a Rust translation for continuity of the wisdom and concision I loved in this guide as a 14 year old.
- deaddodo 3y agoThe only problem is that it wouldn't be quite as useful. Zig, Rust, D, etc offer libraries and methodologies (async/await, for instance) that deprecate traditional raw socket programming. Instead, you would use something like tokio in Rust to do the same thing. You certainly can program raw sockets, the techniques are almost orthogonal to the beej guide. It's the same API and Structs (using FFI) and you would change some glue logic to make it more rust idiomatic. It would just be less useful in those languages, generally.
- davidw 3y agoPre-pandemic, beej used to come to programmer/hacker events here in Bend. Haven't seen him in a while though.
- nickelpro 3y agoThis guide taught me how to program. I owe my entire career to beej
- ghoshbishakh 3y agoThis is a fantastic guide and this was used in our programming lab at IIT Kharagpur. The lab was headed by an equally awesome instructor - Abhijit Das [1] [1] https://cse.iitkgp.ac.in/~abhij/ https://cse.iitkgp.ac.in/~abhij/
- kqr 3y agoOpen question: in what fields are you working where you really need to work with actual sockets? Most of the network programming I do fall into one of two categories: 1. A library exists to abstract over the bytes-into-sockets layer, meaning I don't need to deal with it; or 2. A library probably exists to abstract over the bytes-into-sockets layer, but I've chosen to ignore it either because I'm truly ignorant of it, or for intellectual stimulation. (Note that in category 2 I count things like "not using protobuf/thrift/etc. for IPC.) When are these things not true? Genuinely curious! I'm guessing interfacing with existing obscure third parties, or using obscure language environments, but what are examples of that? And what other usages are there?
- forrestthewoods 3y agoThere is a whole universe of programming that exists outside of webdev. Firmware, video games, high performance systems, etc.
- JustSomeNobody 3y agoThis. I think HN leans very heavy on webdev and somehow forgets that the entire rest of the planet runs on software also.
- DoingIsLearning 3y agoHad plenty of use cases where even zmq was overkill. E.g. interfacing a research machine with an OEM machine or a machine to a standalone embedded target, sometimes it makes sense to just serialize, send over a socket, ethernet crossover cable and be done.
- kqr 3y agoYour description makes it sound sort of like temporary code to perform a one-time (or few-times) job, and not something that's running and maintained for years. Is that a fair characterisation or am I misunderstanding?
- GoblinSlayer 3y ago
- caust1c 3y agoBeej's guides are fantastic. He went to Chico State and I was happy to learn that his books were used for teaching network programming there when I attended. Genuinely inspirational hacker. Feel's great to have had that experience at a state school.
- dang 3y agoRelated (note: reposts are fine after a year or so - https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html): Beej's Guide to Network Programming (1994-2020) - https://news.ycombinator.com/item?id=26100075 https://news.ycombinator.com/item?id=26100075 - Feb 2021 (165 comments) Beej's Guide to Network Programming - https://news.ycombinator.com/item?id=13983212 https://news.ycombinator.com/item?id=13983212 - March 2017 (44 comments) Beej's Guide to Network Programming - https://news.ycombinator.com/item?id=13670971 https://news.ycombinator.com/item?id=13670971 - Feb 2017 (6 comments) Beej's Guide to Network Programming - https://news.ycombinator.com/item?id=12402313 https://news.ycombinator.com/item?id=12402313 - Aug 2016 (4 comments) Beej's Guide to Network Programming (2012) - https://news.ycombinator.com/item?id=9445692 https://news.ycombinator.com/item?id=9445692 - April 2015 (31 comments) Beej's Guide to Network Programming - https://news.ycombinator.com/item?id=7584974 https://news.ycombinator.com/item?id=7584974 - April 2014 (1 comment) Beej's Guide to Network Programming - https://news.ycombinator.com/item?id=5241220 https://news.ycombinator.com/item?id=5241220 - Feb 2013 (47 comments) Beej's Guide to Network Programming - https://news.ycombinator.com/item?id=584557 https://news.ycombinator.com/item?id=584557 - April 2009 (22 comments) Guide to Network Programming - https://news.ycombinator.com/item?id=337371 https://news.ycombinator.com/item?id=337371 - Oct 2008 (7 comments)
- p4bl0 3y agoI love this guide, I gave this link as a reference to my students when I was teaching networks a few years ago. But the last time I looked at it the guide didn't have IPv6 taken into account! Very nice to know that it is now the case! Thanks for posting :).
- jackphilson 3y agoIf you're trying to learn networking, better to start off with the foundational knowledge rather than jump straight into the code. Right now I'm going through the networking section on https://teachyourselfcs.com/ https://teachyourselfcs.com/ which is pretty good so far.
- ascar 3y agoContrary to popular belief, formal education wasn't useless here. All the foundational knowledge was covered in depth in my mandatory CS undergrad networking class. So this is a neat quick guide to all the stuff CS graduates already have learned once about but might've forgotten the details or don't know the hands on code.
- samtho 3y agoI think there is (or was, depending on the institution) a disconnect between the curriculum and what skills students needed. For context, I was a tutor, instructional assistant, adjunct professor, and finally a curriculum advisor for the Los Rios Community College system and the University of California Davis Extension. First, CS programs that went 100% into Java did not age well and most of these courses were taught in a way that led students on to believe this stuff was static and won’t really improve. The concept of new languages beyond what was available in circa 2006 was unimaginable. Another quirk that a Java-centric education brought on was that low-level courses were often taught in Java and you ended up writing all your data structures coursework in Java taught by someone with a C background. But you couldn’t use C or anything sensible for this because universities promised students would know object oriented programming. This created a lot of disconnect and meaningless ritual around a paradigm that did not fit the language. CS programs that succeeded understood that a foundational knowledge coupled with language flexibility. They had to understand that the specific languages did not matter so much, rather it should fit the paradigm and principles of the context in which it was written. Once students are able to think in terms of computer procedures, instructors can leverage this knowledge to introduce abstractions and a grand unification principle.
- Dowwie 3y agoI've been working on the Protohackers [1] exercises in Elixir, putting my own spin on the problems by creating fault tolerant, scalable, high performance solutions-- and have been touching a lot of Elixir that I haven't had the opportunity to otherwise. The "Unusual Database" problem, particularly, has become a very deep rabbit hole assignment as it involves a UDP-based KV database. I stopped just short of clustering. Writing servers in Elixir is straightforward because of the foundation exposed by Erlang's gen_tcp and gen_udp libraries. When you want to take your TCP server up a notch, try TCP acceptor pooling. There are two viable TCP acceptor pool libraries: Thousand Island, written in pure Elixir, and Ranch, written in Erlang. Because of these well- abstracted foundation libraries and acceptor pool libraries, it's possible to write robust servers without venturing much into low level network programming. Beej explains the lowest level details well. I've done some of the equivalent work in Rust but found the slow progress of my work unsatisfying and moved back to Elixir quickly. [1] protohackers.com
- coyotespike 3y agoBeej wrote the first computer science curriculum for Lambda School, which accounts for its initial breadth and depth. I taught there so I could learn CS, spending many hours to learn each class before teaching it. One of my favorite modules he designed was on computer architecture. We simulated the CPU and registers in Python (they switched from C right before I got there), and each class extended our instruction set. Teaching his modules taught me enough that I was able to start the MSCS program at UT Austin.