Java Network Programming (4th Edition)
Tags
Summary
This book is the Chinese translation of the fourth edition of O'Reilly's classic Java Network Programming, a practical-oriented guide to Java network programming. It begins with foundational concepts such as network layering, TCP/IP and UDP, streams, and threads, then gradually goes deeper into the concrete use of Java's networking class libraries: handling Internet addresses with InetAddress and NetworkInterface; locating and reading network resources with URL, URI, and URLConnection; exploring the HTTP protocol, request headers, cookies, and caching; and writing multithreaded clients and servers with Socket and ServerSocket. Building on this, the book also discusses JSSE secure sockets and encrypted communication, NIO buffers and channels, readiness selection and non-blocking I/O, as well as UDP datagrams, DatagramChannel, and IP multicast. The fourth edition has been thoroughly revised to incorporate then-new technologies such as REST, SPDY, and asynchronous I/O, and is accompanied by numerous runnable example code. Readers can both understand protocol principles and follow the examples to complete common network programming tasks.
Editor's review
如果你写过 Java 却只会用别人封装好的 HTTP 工具,这本书能帮你补上底层这一课。作者 Elliotte Rusty Harold 写 Java 网络程序近二十年,讲法一贯是「先讲协议、再看 API、最后给能跑的代码」,本书延续了这一风格:从 TCP/IP 分层、流与线程这些容易被略过的基础开始,再一层层推进到 URLConnection、Socket、SSL、NIO 与 UDP 组播。第四版在旧版基础上做了大幅修订,补充了 REST、SPDY、异步 I/O 等内容,对理解现代 Java 网络栈的来路很有帮助。全书示例完整、可操作性很强,既适合系统通读,也适合当作网络类库的案头参考。需要注意的是,本书成书较早,示例基于当时的 JDK 版本,部分 API 与今天的主流实践已有差距,阅读时最好配合官方文档同步对照。
Who it's for
A good fit for
- 已掌握 Java 基础语法、想弄清网络底层机制的开发者
- 需要手写 Socket 服务器或自定义协议的工程师
- 准备面试或系统复习 Java I/O、NIO、HTTP 知识的人
- 想把零散的网络知识串成体系的高校学生与自学者
Not a good fit for
- 完全没有 Java 基础、刚入门的编程初学者
- 只想要 Spring 等框架快速上手教程的读者
- 期待覆盖 HTTP/2、HTTP/3 等最新协议细节的人
Reading tips
- 先通读第1至3章打牢协议、流与线程基础,再按需选读后续章节
- 每章示例动手敲一遍,并用 Wireshark 或 Telnet 观察实际网络交互
- 涉及 NIO 与 SSL 的章节可结合当前 JDK 官方文档对照阅读,留意 API 变更
- 把本书当作工具书长期放在案头,遇到具体网络问题时按类库章节查阅
Contents
- Preface
- Chapter 1 Basic Network Concepts
- Chapter 2 Streams
- Chapter 3 Threads
- Chapter 4 Internet Addresses
- Chapter 5 URLs and URIs
- Chapter 6 HTTP
- Chapter 7 URLConnection
- Chapter 8 Client Sockets
- Chapter 9 Server Sockets
- Chapter 10 Secure Sockets
- Chapter 11 Nonblocking I/O
- Chapter 12 UDP
- Chapter 13 IP Multicast
FAQ
这本书有第三版和第四版,该选哪个?
第三版由朱涛江、林剑翻译,2005年出版,基于 JDK 1.4/1.5,篇幅更大;第四版由李帅、荆涛翻译,2014年出版,修订后涵盖 REST、SPDY、异步 I/O 等内容。一般建议选第四版,除非你有特定需要查阅旧版内容。
书里的示例代码在今天还能跑吗?
大部分核心示例(Socket、URL、NIO 等)思路仍然适用,但书中基于当时 JDK,部分 API 已弃用或被替代,例如旧版日期与部分 HTTP 相关类。建议在较新的 JDK 上运行并参照官方文档调整。
零基础能直接读这本书吗?
不太推荐。本书假定读者已会写 Java 程序、了解基本的多线程概念,开篇就直接进入网络分层与流模型。零基础读者宜先学完 Java 语法与集合、异常、线程基础再回来。
这本书和《Java并发编程实战》有什么区别?
两者关注点不同:本书聚焦网络 I/O、协议与 Socket 编程,线程只是为编写多线程服务器服务;后者系统讲解并发模型、线程安全与同步机制。若要做网络服务端,两本可以配合阅读。
Comments
Find this book
This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.