《Java网络编程 第4版》PDF下载

  • 购买积分:15 如何计算积分?
  • 作  者:Elliotte Rusty Harold著
  • 出 版 社:南京:东南大学出版社
  • 出版年份:2014
  • ISBN:9787564149604
  • 页数:480 页
图书介绍:这是一本实用指南,完整地介绍了基于Java开发网络程序。你将了解到如何使用Java的网络类库来快速、简便地完成常见的网络任务,比如,编写多线程服务器、加密通信、在局域网进行广播和发送数据到服务器端程序等。

1.Basic Network Concepts 1

Networks 2

The Layers of a Network 4

The Host-to-Network Layer 7

The Internet Layer 8

The Transport Layer 9

The Application Layer 10

IP,TCP,and UDP 10

IP Addresses and Domain Names 11

Ports 13

The Internet 14

Internet Address Blocks 15

Network Address Translation 15

Firewalls 15

Proxy Servers 16

The Client/Server Model 18

Internet Standards 19

IETF RFCs 20

W3C Recommendations 22

2.Streams 25

Output Streams 26

Input Streams 31

Marking and Resetting 34

Filter Streams 35

Chaining Filters Together 37

Buffered Streams 38

PrintStream 39

Data Streams 41

Readers and Writers 44

Writers 45

OutputStream Writer 47

Readers 47

Filter Readers and Writers 49

PrintWriter 51

3.Threads 53

Running Threads 55

Subclassing Thread 56

Implementing the Runnable Interface 58

Returning Information from a Thread 60

Race Conditions 61

Polling 63

Callbacks 63

Futures,Callables,and Executors 68

Synchronization 70

Synchronized Blocks 72

Synchronized Methods 74

Alternatives to Synchronization 75

Deadlock 77

Thread Scheduling 78

Priorities 78

Preemption 79

Thread Pools and Executors 89

4.Internet Addresses 93

The InetAddress Class 95

Creating New InetAddress Objects 95

Getter Methods 100

Address Types 102

Testing Reachability 106

Object Methods 106

Inet4Address and Inet6Address 107

The NetworkInterface Class 108

Factory Methods 108

Getter Methods 110

Some Useful Programs 111

SpamCheck 111

Processing Web Server Logfiles 112

5.URLs and URIs 117

URIs 117

URLs 120

Relative URLs 122

The URL Class 123

Creating New URLs 123

Retrieving Data from a URL 128

Splitting a URL into Pieces 135

Equality and Comparison 139

Conversion 141

The URI Class 141

Constructing a URI 142

The Parts of the URI 144

Resolving Relative URIs 147

Equality and Comparison 148

String Representations 149

x-www-form-urlencoded 149

URLEncoder 150

URLDecoder 154

Proxies 154

System Properties 155

The Proxy Class 155

The ProxySelector Class 156

Communicating with Server-Side Programs Through GET 157

Accessing Password-Protected Sites 161

The Authenticator Class 162

The PasswordAuthentication Class 164

The JPasswordField Class 164

6.HTTP 169

The Protocol 169

Keep-Alive 175

HTTP Methods 177

The Request Body 179

Cookies 181

CookieManager 184

CookieStore 185

7.URLConnections 187

Opening URLConnections 188

Reading Data from a Server 189

Reading the Header 190

Retrieving Specific Header Fields 191

Retrieving Arbitrary Header Fields 197

Caches 199

Web Cache for Java 203

Configuring the Connection 208

protected URL url 209

protected boolean connected 209

protected boolean allowUserInteraction 210

protected boolean doInput 211

protected boolean doOutput 212

protected boolean ifModifiedSince 212

protected boolean useCaches 214

Timeouts 215

Configuring the Client Request HTTP Header 215

Writing Data to a Server 218

Security Considerations for URLConnections 223

Guessing MIME Media Types 224

HttpURLConnection 224

The Request Method 225

Disconnecting from the Server 229

Handling Server Responses 230

Proxies 235

Streaming Mode 235

8.Sockets for Clients 237

Using Sockets 237

Investigating Protocols with Telnet 238

Reading from Servers with Sockets 240

Writing to Servers with Sockets 246

Constructing and Connecting Sockets 251

Basic Constructors 251

Picking a Local Interface to Connect From 253

Constructing Without Connecting 254

Socket Addresses 255

Proxy Servers 256

Getting Information About a Socket 257

Closed or Connected? 258

toString() 259

Setting Socket Options 259

TCP_NODELAY 260

SO_LINGER 261

SO_TIMEOUT 261

SO_RCVBUF and SO_SNDBUF 262

SO_KEEPALIVE 263

OOBINLINE 264

SO_REUSEADDR 265

IP_TOS Class of Service 265

Socket Exceptions 267

Sockets in GUI Applications 268

Whois 269

A Network Client Library 272

9.Sockets for Servers 283

Using ServerSockets 283

Serving Binary Data 288

Multithreaded Servers 289

Writing to Servers with Sockets 293

Closing Server Sockets 295

Logging 297

What to Log 297

How to Log 298

Constructing Server Sockets 302

Constructing Without Binding 304

Getting Information About a Server Socket 305

Socket Options 306

SO_TIMEOUT 307

SO_REUSEADDR 308

SO_RCVBUF 308

Class of Service 309

HTTP Servers 309

A Single-File Server 310

A Redirector 314

A Full-Fledged HTTP Server 319

10.Secure Sockets 325

Secure Communications 326

Creating Secure Client Sockets 328

Choosing the Cipher Suites 332

Event Handlers 336

Session Management 336

Client Mode 338

Creating Secure Server Sockets 339

Configuring SSLServerSockets 343

Choosing the Cipher Suites 343

Session Management 344

Client Mode 344

11.Nonblocking I/O 347

An Example Client 349

An Example Server 353

Buffers 359

Creating Buffers 361

Filling and Draining 363

Bulk Methods 364

Data Conversion 365

View Buffers 368

Compacting Buffers 370

Duplicating Buffers 372

Slicing Buffers 376

Marking and Resetting 377

Object Methods 377

Channels 378

SocketChannel 378

ServerSocketChannel 381

The Channels Class 383

Asynchronous Channels(Java 7) 384

Socket Options(Java 7) 386

Readiness Selection 388

The Selector Class 388

The SelectionKey Class 390

12.UDP 393

The UDP Protocol 393

UDP Clients 395

UDP Servers 397

The DatagramPacket Class 399

The Constructors 401

The get Methods 403

The setter Methods 406

The DatagramSocket Class 408

The Constructors 409

Sending and Receiving Datagrams 411

Managing Connections 416

Socket Options 417

SO_TIMEOUT 417

SO_RCVBUF 418

SO_SNDBUF 419

SO_REUSEADDR 419

SO_BROADCAST 419

IP_TOS 420

Some Useful Applications 421

Simple UDP Clients 421

UDPServer 425

A UDP Echo Client 428

DatagramChannel 431

Using DatagramChannel 431

13.IP Multicast 443

Multicasting 444

Multicast Addresses and Groups 447

Clients and Servers 450

Routers and Routing 452

Working with Multicast Sockets 453

The Constructors 454

Communicating with a Multicast Group 455

Two Simple Examples 460

Index 465