“If you want to understand sockets, there's no excuse for not reading Beej's Guide to Network Programming [1].”
Brian Hall(Beej)写的网络编程指南,以 C 语言讲 Berkeley 套接字 API,覆盖 IPv4 与 IPv6、TCP 与 UDP、客户端与服务器的写法,并附有可运行的示例代码。语言口语化、好读,重点放在动手写出能工作的程序。内容偏经典,主要讲阻塞 I/O 和 select(),而不是现代的异步框架。
HN 上的人长期把它当作学套接字的标准起点:写得清楚、容易读,有人自己或在课上用它入门,常说它是最好的免费编程书之一。也有人提醒它偏老派,只讲阻塞 I/O 和 select(),还有人觉得其中的服务器示例代码有些绕。
想用 C 理解套接字与网络编程的人
怎么读
由 Claude 根据这本书和 HN 上的说法整理,可能有错- 1先快速读背景部分,再从套接字基本调用读起
- 2照着示例代码自己敲一遍客户端和服务器
- 3读完后想了解高并发,再另找 epoll 或异步 I/O 的资料
- 4与作者的 C 语言指南配合着读
HN 书评
推荐在前,同类按时间 · 每本最多保留 20 条,统计用全部提及 · 作者本人贴的不算“My favorite free programming books are anything by Beej. His networking[0] and C[1] books are simply phenomenal.”
“This is by far the best networking book I have read.”
“Have you tried understanding the Berkeley Sockets API with C? There are some good sites that cover basics: Beej's Guide to Network Programming”
“just in case anybody hasn't seen it, beej's guide to networking is pretty nice. Beej's Guide to Network Programming”
“This is probably a little too entry level but it makes a good reference.”
看全部 20 条 →
“Beej's Guide shows how to use the C socket APIs in a dual-stack manner:”
“Oh, and start here, if anywhere: Beej's Guide to Network Programming”
“Learn about networking with sockets: Beej's Guide to Network Programming”
“This is a very readable online book on networking and sockets:”
“People recommend Beej's tutorials, which are quite comprehensive and a good source of information, but I found some of his server code confusing and convoluted”
“Read Beej's C and network programming guides. Get a Free UNIX, download the source for simple utilities and tinker.”
“There's always the classic Beej's Guide to Network Programming [0], which is pretty low-level but something I always point to when mentoring.”
“Beej's Guide to Network programming is also pretty good. It was effectively used as the textbook in my networking class.”
“It's definitely worth reading, but be aware that it's quite old-fashioned in that it focuses entirely on blocking I/O and select().”
“I remember using Beej's guide to learn how to do TCP/IP stuff in C around ten years ago. Very well written and easy to follow.”
“I found beej's guide useful as well.”
“When I was a kid I taught myself network programming with Beej's guide: Beej's Guide to Network Programming”
“Beej's guides are great! He does a fantastic job of describing concepts and showing implementations. I also recommend his networking guide: Beej's Guide to Network Programming”
“If you are interested in learning a lot of those at the same time, write a server in C.”