News for hackers. Stuff that matters.
Re:Beej's Guide to Network Programming by daave on Monday February 18, 2013 @08:00PM (#5241934)
When I was at university I wanted to take a class that had 'introduction to computer networks' as a prerequisite, but I didn't want to wait 2 semesters for it to come around again after taking networks first. I spoke to the professor and he said he'd let me enroll in the course if I promised to carefully read Beej's guide first, since it contains all the essentials I'd really need for this follow-on. So, this saved me 6 months, what a golden nugget!
Re:Beej's Guide to Network Programming by kenkam on Tuesday February 19, 2013 @04:40AM (#5243473)
Same here. My course was a simple one and didn't include network programming, and at the same time I was learning about select() and co in C. This was a great primer especially for me as I had some Python knowledge; it really helped with understanding network programming at a lower level.

Even if you don't code the examples, reading them will give you so much information.

Re:Beej's Guide to Network Programming by abhididdigi on Monday February 18, 2013 @11:56PM (#5242707)
+1, The same happened with me too. In my university, the professor teaching Computer Networks never understood about computer networks, forget UNIX, he used to come to class mugging some programs up. This guide helped a lot to start with UNIX, I was so overwhelmed that i went on and sent fan mail to beej xD.
Re:Beej's Guide to Network Programming by ambrop7 on Monday February 18, 2013 @08:34PM (#5242057)
Still not updated to mention anything more than select() as far as non-blocking IO is concerned, like poll, epoll, or, god no, using an abstract event loop. Nobody who cares about their code and sanity does blocking I/O with sockets.

But then, I must confess I too started network programming with this guide :) It presents the basics nicely, but there's a lot more you should learn about network programming.

Re:Beej's Guide to Network Programming by asveikau on Monday February 18, 2013 @09:13PM (#5242193)
It looks like he did put in a blurb about using libevent in order to use a more modern syscall under the hood - it's disappointing though that he didn't explain why epoll and kqueue are better though, people who are new to this would be much better served by that than by any code samples involving select().
Re:Beej's Guide to Network Programming by jcheng on Monday February 18, 2013 @09:10PM (#5242180)
Are you saying "god no" to using an abstract event loop? If so, why? (I've been using libuv for a project, so far so good.)
Re:Beej's Guide to Network Programming by ambrop7 on Monday February 18, 2013 @10:13PM (#5242375)
No, of course not, I was just referring the the reluctance of the book to get modernized. I can't possibly imagine not using an abstract event loop.
Re:Beej's Guide to Network Programming by jcheng on Tuesday February 19, 2013 @08:32PM (#5248419)
Ah, "God forbid"--gotcha.
Re:Beej's Guide to Network Programming by kqr2 on Monday February 18, 2013 @08:37PM (#5242068)
Is there a similar or updated guide some place which includes non-blocking i/o?
Re:Beej's Guide to Network Programming by krenoten on Monday February 18, 2013 @09:04PM (#5242159)
Check out "The C10K Problem" (http://www.kegel.com/c10k.html) for a high level discussion of some techniques for high performance servers.

For basic info on Epoll: http://www.devshed.com/c/a/BrainDump/Linux-Files-and-the-Eve... epoll socket tutorial: http://kovyrin.net/2006/04/13/epoll-asynchronous-network-pro...

Or kqueue if your OS supports it: http://wiki.netbsd.org/tutorials/kqueue_tutorial/

Lower level details on level triggered vs edge triggered interrupts: http://en.wikipedia.org/wiki/Interrupt#Level-triggered

Overview of the thundering herd problem: http://www.citi.umich.edu/projects/linux-scalability/reports...

Re:Beej's Guide to Network Programming by halayli on Tuesday February 19, 2013 @06:58AM (#5243832)
Take a look at lthread http://github.com/halayli/lthread
Re:Beej's Guide to Network Programming by n0ndescript on Monday February 18, 2013 @09:23PM (#5242231)
There is http://www.wangafu.net/~nickm/libevent-book/ which is useful even if you are not using libevent (which most of the cool kids are)
Re:Beej's Guide to Network Programming by stefantalpalaru on Monday February 18, 2013 @10:03PM (#5242341)
Some of those cool kids should take a look at libev: http://software.schmorp.de/pkg/libev.html
Re:Beej's Guide to Network Programming by simfoo on Tuesday February 19, 2013 @04:26AM (#5243435)
Re:Beej's Guide to Network Programming by tezka on Monday February 18, 2013 @08:35PM (#5242064)
it's a shortcut to learn basic network programming with sockets, without spending too much time on it. Anyone more than casually serious about it should consider looking at Richard Stevens books, Unix network programming and TCP/IP illustrated (esp. volume 2).
Re:Beej's Guide to Network Programming by segmondy on Tuesday February 19, 2013 @12:13PM (#5245488)
I'm shocked that you are the only one to mention rstevens, It won't be far fetched if Beej learned from rstevens.
Re:Beej's Guide to Network Programming by philhippus on Tuesday February 19, 2013 @06:39AM (#5243771)
For this community, I would have thought this is a bit like seeing a link to Google.com on the HN front page. Beej's guide is staple internet fodder.
Re:Beej's Guide to Network Programming by sp332 on Monday February 18, 2013 @05:39PM (#5241252)
This was an absolute lifesaver when I was thrown into the deep end writing a high-performance TCP server from scratch. I think it's so effective because it's "highly opinionated", which is to say, he points out "Foo does this, but don't use it because that's just silly" or "don't use bar, use baz instead because it handles qux more easily" and so on.
Re:Beej's Guide to Network Programming by tezka on Monday February 18, 2013 @08:31PM (#5242043)
what makes this stuff seem "high-performance" TCP to you? This is standard socket programming. High performance TCP server is when you actually roll out your own TCP stack.
Re:Beej's Guide to Network Programming by sp332 on Monday February 18, 2013 @08:57PM (#5242130)
Fair enough, to be honest the tcp part was not really the bottleneck. But servicing multiple incoming streams without starving any is really what i meant.
Re:Beej's Guide to Network Programming by mattpardee on Monday February 18, 2013 @07:45PM (#5241857)
If I'm not mistaken this original document was on Chico State's computer science domain. It was my understanding Beej went to Chico; does anyone know for sure? This was around long before 2006, I remember reading it around the year 2000 when I was first getting into C++. (miracle this quality of a document escaped anyone's brain in Chico -- I know, I went to CSUC. Let's just say it was hard to concentrate there :)
Re:Beej's Guide to Network Programming by asveikau on Monday February 18, 2013 @07:57PM (#5241920)
I also remember seeing this around the year 2000. (One giveaway that it's written in a previous century: It mentions SunOS. Not Solaris, but SunOS. When's the last time you heard somebody talk about that?) At that point I was already familiar with sockets, and mainly found the guide memorable because the name "Beej" had a weird sound to it.
Re:Beej's Guide to Network Programming by jlgaddis on Monday February 18, 2013 @11:49PM (#5242685)
Chico does sound familiar for some reason, with regard to this guide (I also recall reading it many years ago, probably a decade ago or more). I skimmed through it quickly for a version history but didn't see one.
Re:Beej's Guide to Network Programming by blaabjerg on Monday February 18, 2013 @11:07PM (#5242546)
Yep, he went to Chico from 1993 to 1997 according to his LinkedIn profile: https://www.linkedin.com/in/brianhall
Re:Beej's Guide to Network Programming by pm90 on Monday February 18, 2013 @10:18PM (#5242393)
I'm curious as to why its hard to concentrate, is it a party school or does it have its own beach like UCSB or what?
Re:Beej's Guide to Network Programming by mattpardee on Monday February 18, 2013 @11:32PM (#5242620)
Party school.
Re:Beej's Guide to Network Programming by hlmtre on Monday February 18, 2013 @07:59PM (#5241927)
He did indeed. Chico State's CSCI program was actually very good in the early 90s.
Re:Beej's Guide to Network Programming by wuest on Tuesday February 19, 2013 @10:04AM (#5244614)
This is one of those priceless documents that served me well, and which I have recommended to many others as a great starting place.
Re:Beej's Guide to Network Programming by X-Istence on Monday February 18, 2013 @08:21PM (#5242008)
Still refer to it every so often, especially as backup documentation from the man pages when something isn't entirely clear.
Re:Beej's Guide to Network Programming by thrush on Monday February 18, 2013 @07:25PM (#5241773)
learning from this now. glad its got all this credibility! (context: college operating systems course)
Re:Beej's Guide to Network Programming by krenoten on Monday February 18, 2013 @08:36PM (#5242067)
If you want to learn about some more advanced strategies, you may also benefit from this classic: http://www.kegel.com/c10k.html
Re:Beej's Guide to Network Programming by curiousDog on Monday February 18, 2013 @07:32PM (#5241796)
Like others, this is how i learned to do it too. The C programming guide is very good too
Re:Beej's Guide to Network Programming by infoseckid on Monday February 18, 2013 @09:11PM (#5242182)
I owe this guy my entry into network programming and eventually security.
Re:Beej's Guide to Network Programming by shurcooL on Monday February 18, 2013 @09:24PM (#5242235)
I owe him the implementation details part of my networking code for my game from 5~ years back.
Re:Beej's Guide to Network Programming by enterx on Tuesday February 19, 2013 @04:25AM (#5243432)
lol soooo retro! brings back memories almost 10 years old. i used it as a guideline for writing an SMS notifier on incoming e-mails through free HTTP SMS service. with auth. ;)
Re:Beej's Guide to Network Programming by lightblade on Tuesday February 19, 2013 @04:12PM (#5247063)
+1 !!

This is the number one thing that got me through network class back in university. Next to that is the professor's office hour. I don't think I even touched the textbook.

Re:Beej's Guide to Network Programming by novamantis on Tuesday February 19, 2013 @06:28AM (#5243746)
Is there an even better, more modern networking guide that's free (or not)? Does anyone have a list of networking reference/tutorial/introduction material?
Re:Beej's Guide to Network Programming by tumanian on Monday February 18, 2013 @07:13PM (#5241724)
Wow, I am glad that this is still around - the first tutorial that I learned socket and network programming back in 2004.
Re:Beej's Guide to Network Programming by paolord on Tuesday February 19, 2013 @02:05AM (#5243066)
Its nice to know other guys learned from this as well. Makes me feel that what I learned back in college was legit.
Re:Beej's Guide to Network Programming by demian on Monday February 18, 2013 @06:56PM (#5241664)
This saved me when I had to write a P2P file distribution system for a project in college.
Re:Beej's Guide to Network Programming by jcknight on Monday February 18, 2013 @07:39PM (#5241825)
This was the go-to guide back in its times. Circa 2006?
Re:Beej's Guide to Network Programming by CoryG89 on Monday February 18, 2013 @07:38PM (#5241817)
This was my first look at networking. Worked for me.
Re:Beej's Guide to Network Programming by dashN9ne on Monday February 18, 2013 @06:47PM (#5241628)
I learned from this in 2006-2007.
Re:Beej's Guide to Network Programming by markwong on Monday February 18, 2013 @09:23PM (#5242230)
truely classics. i learned network programming from this guide a decade ago.
Re:Beej's Guide to Network Programming by xtremejames183 on Monday February 18, 2013 @08:33PM (#5242049)
A reference for beginners!
Re:Beej's Guide to Network Programming by nillort on Tuesday February 19, 2013 @12:39AM (#5242849)
At first, I was confused, thinking that the porn site beeg.com posted a networking tutorial.
Re:Beej's Guide to Network Programming by L0j1k on Monday February 18, 2013 @06:33PM (#5241570)
This is how I learned to do it.