Live data from Hacker News

Beej's Guide to Network Programming

beej.us

21–30 of 51 posts

Re: Beej's Guide to Network Programming

#21
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

#24
post #18
post #2

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.

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.

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

#25
post #23

Is there a similar or updated guide some place which includes non-blocking i/o?

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

#26
post #20

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.

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

#28
post #20

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.

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().
Post reply on HN