内容简介
1.Basic Network Concepts
Networks
The Layers of a Network
The Host-to-Network Layer
The Internet Layer
The Transport Layer
The Application Layer
IP,TCP,and UDP
IP Addresses and Domain Names
Ports
The Internet
Internet Address Blocks
Network Address Translation
Firewalls
Proxy Servers
The Client/Server Model
Internet Standards
IETF RFCs
W3C Recommendations
2.Streams
Output Streams
Input Streams
Marking and Resetting
Filter Streams
Chaining Filters Together
Buffered Streams
PrintStream
Data Streams
Readers and Writers
Writers
OutputStream Writer
Readers
Filter Readers and Writers
PrintWriter
3.Threads
Running Threads
Subclassing Thread
Implementing the Runnable Interface
Returning Information from a Thread
Race Conditions
Polling
Callbacks
Futures,Callables,and Executors
Synchronization
Synchronized Blocks
Synchronized Methods
Alternatives to Synchronization
Deadlock
Thread Scheduling
Priorities
Preemption
Thread Pools and Executors
4.Internet Addresses
The InetAddress Class
Creating New InetAddress Objects
Getter Methods
Address Types
Testing Reachability
Object Methods
Inet4Address and Inet6Address
The NetworkInterface Class
Factory Methods
Getter Methods
Some Useful Programs
SpamCheck
Processing Web Server Logfiles
5.URLs and URIs
URIs
URLs
Relative URLs
The URL Class
Creating New URLs
Retrieving Data from a URL
Splitting a URL into Pieces
Equality and Comparison
Conversion
The URI Class
Constructing a URI
The Parts of the URI
Resolving Relative URIs
Equality and Comparison
String Representations
x-www-form-urlencoded
URLEncoder
URLDecoder
Proxies
System Properties
The Proxy Class
The ProxySelector Class
Communicating with Server-Side Programs Through GET
Accessing Password-Protected Sites
The Authenticator Class
The PasswordAuthentication Class
The JPasswordField Class
6.HTTP
The Protocol
Keep-Alive
HTTP Methods
The Request Body
Cookies
CookieManager
CookieStore
7.URLConnections
Opening URLConnections
Reading Data from a Server
Reading the Header
Retrieving Specific Header Fields
Retrieving Arbitrary Header Fields
Caches
Web Cache for Java
Configuring the Connection
protected URL url
protected boolean connected
protected boolean allowUserInteraction
protected boolean doInput
protected boolean doOutput
protected boolean ifModifiedSince
protected boolean useCaches
Timeouts
Configuring the Client Request HTTP Header
Writing Data to a Server
Security Considerations for URLConnections
Guessing MIME Media Types
HttpURLConnection
The Request Method
Disconnecting from the Server
Handling Server Responses
Proxies
Streaming Mode
8.Sockets for Clients
Using Sockets
Investigating Protocols with Telnet
Reading from Servers with Sockets
Writing to Servers with Sockets
Constructing and Connecting Sockets
Basic Constructors
Picking a Local Interface to Connect From
Constructing Without Connecting
Socket Addresses
Proxy Servers
Getting Information About a Socket
Closed or Connected?
toString()
Setting Socket Options
TCP_NODELAY
SO_LINGER
SO_TIMEOUT
SO_RCVBUF and SO_SNDBUF
SO_KEEPALIVE
OOBINLINE
SO_REUSEADDR
IP_TOS Class of Service
Socket Exceptions
Sockets in GUI Applications
Whois
A Network Client Library
9.Sockets for Servers
Using ServerSockets
Serving Binary Data
Multithreaded Servers
Writing to Servers with Sockets
Closing Server Sockets
Logging
What to Log
How to Log
Constructing Server Sockets
Constructing Without Binding
Getting Information About a Server Socket
Socket Options
SO_TIMEOUT
SO_REUSEADDR
SO_RCVBUF
Class of Service
HTTP Servers
A Single-File Server
A Redirector
A Full-Fledged HTTP Server
10.Secure Sockets
Secure Communications
Creating Secure Client Sockets
Choosing the Cipher Suites
Event Handlers
Session Management
Client Mode
Creating Secure Server Sockets
Configuring SSLServerSockets
Choosing the Cipher Suites
Session Management
Client Mode
11.Nonblocking I/O
An Example Client
An Example Server
Buffers
Creating Buffers
Filling and Draining
Bulk Methods
Data Conversion
View Buffers
Compacting Buffers
Duplicating Buffers
Slicing Buffers
Marking and Resetting
Object Methods
Channels
SocketChannel
ServerSocketChannel
The Channels Class
Asynchronous Channels(Java 7)
Socket Options(Java 7)
Readiness Selection
The Selector Class
The SelectionKey Class
12.UDP
The UDP Protocol
UDP Clients
UDP Servers
The DatagramPacket Class
The Constructors
The get Methods
The setter Methods
The DatagramSocket Class
The Constructors
Sending and Receiving Datagrams
Managing Connections
Socket Options
SO_TIMEOUT
SO_RCVBUF
SO_SNDBUF
SO_REUSEADDR
SO_BROADCAST
IP_TOS
Some Useful Applications
Simple UDP Clients
UDPServer
A UDP Echo Client
DatagramChannel
Using DatagramChannel
13.IP Multicast
Multicasting
Multicast Addresses and Groups
Clients and Servers
Routers and Routing
Working with Multicast Sockets
The Constructors
Communicating with a Multicast Group
Two Simple Examples
Index