100% found this document useful (7 votes)
34 views

(Ebook) Java Network Programming by Harold, Elliotte ISBN 9781449357672, 1449357679 All Chapters Instant Download

The document provides information about the ebook 'Java Network Programming' by Elliotte Rusty Harold, including its ISBN and links for downloading. It outlines the content structure of the book, which covers various topics related to network programming in Java, including basic network concepts, streams, threads, URLs, HTTP, and secure sockets. Additionally, it mentions other related ebooks available on the same platform.

Uploaded by

eliosiraggl
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (7 votes)
34 views

(Ebook) Java Network Programming by Harold, Elliotte ISBN 9781449357672, 1449357679 All Chapters Instant Download

The document provides information about the ebook 'Java Network Programming' by Elliotte Rusty Harold, including its ISBN and links for downloading. It outlines the content structure of the book, which covers various topics related to network programming in Java, including basic network concepts, streams, threads, URLs, HTTP, and secure sockets. Additionally, it mentions other related ebooks available on the same platform.

Uploaded by

eliosiraggl
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Download Full Version ebook - Visit ebooknice.

com

(Ebook) Java Network Programming by Harold,


Elliotte ISBN 9781449357672, 1449357679

https://ebooknice.com/product/java-network-
programming-55585978

Click the button below to download

DOWLOAD EBOOK

Discover More Ebook - Explore Now at ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Java Network Programming by Elliotte Rusty Harold


ISBN 9781449357672, 1449357679

https://ebooknice.com/product/java-network-programming-4427642

ebooknice.com

(Ebook) Java Network Programming, Third Edition by


Elliotte Rusty Harold ISBN 9780596007218, 0596007213

https://ebooknice.com/product/java-network-programming-third-
edition-2332242

ebooknice.com

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason;


Viles, James ISBN 9781459699816, 9781743365571,
9781925268492, 1459699815, 1743365578, 1925268497
https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

ebooknice.com

(Ebook) Java I/O by Elliotte Rusty Harold ISBN


9781565924857, 1565924851

https://ebooknice.com/product/java-i-o-38436468

ebooknice.com
(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena
Alfredsson, Hans Heikne, Sanna Bodemyr ISBN 9789127456600,
9127456609
https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

ebooknice.com

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT


II Success) by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018

ebooknice.com

(Ebook) XML Bible by Elliotte Rusty Harold ISBN


9780764547607, 0764547607

https://ebooknice.com/product/xml-bible-923002

ebooknice.com

(Ebook) XML Bible, Gold Edition by Elliotte Rusty Harold


ISBN 9780764548192, 0764548190

https://ebooknice.com/product/xml-bible-gold-edition-1927878

ebooknice.com

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master


the SAT Subject Test: Math Levels 1 & 2) by Arco ISBN
9780768923049, 0768923042
https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094

ebooknice.com
FOURTH EDITION

Java Network Programming

Elliotte Rusty Harold


Java Network Programming, Fourth Edition
by Elliotte Rusty Harold
Copyright © 2014 Elliotte Rusty Harold. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or [email protected].
Editor: Meghan Blanchette Indexer: Judy McConville
Production Editor: Nicole Shelby Cover Designer: Randy Comer
Copyeditor: Kim Cofer Interior Designer: David Futato
Proofreader: Jasmine Kwityn Illustrator: Rebecca Demarest

October 2013: Fourth Edition

Revision History for the Fourth Edition:


2013-09-23: First release

See http://oreilly.com/catalog/errata.csp?isbn=9781449357672 for release details.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. Java Network Programming, the image of a North American river otter, and related trade dress
are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐
mark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.

ISBN: 978-1-449-35767-2
[LSI]
This book is dedicated to my dog, Thor.
Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

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

v
PrintStream 39
Data Streams 41
Readers and Writers 44
Writers 45
OutputStreamWriter 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

vi | Table of Contents
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

Table of Contents | vii


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

viii | Table of Contents


Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
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

Table of Contents | ix
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

x | Table of Contents
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

Table of Contents | xi
Preface

Java’s growth over the past 20 years has been nothing short of phenomenal. Given Java’s
rapid rise to prominence and the even more spectacular growth of the Internet, it’s a
little surprising that network programming in Java remains so mysterious to so many.
It doesn’t have to be. In fact, writing network programs in Java is quite simple, as this
book will show. Readers with previous experience in network programming in a Unix,
Windows, or Macintosh environment will be pleasantly surprised at how much easier
it is to write equivalent programs in Java. The Java core API includes well-designed
interfaces to most network features. Indeed, there is very little application layer network
software you can write in C or C++ that you can’t write more easily in Java. Java Network
Programming, Fourth Edition, endeavors to show you how to take advantage of Java’s
network class library to quickly and easily write programs that accomplish many com‐
mon networking tasks. Some of these include:

• Browsing the Web with HTTP


• Writing multithreaded servers
• Encrypting communications for confidentiality, authentication, and guaranteed
message integrity
• Designing GUI clients for network services
• Posting data to server-side programs
• Looking up hosts using DNS
• Downloading files with anonymous FTP
• Connecting sockets for low-level network communication
• Multicasting to all hosts on the network

Java is the first (though no longer the only) language to provide such a powerful cross-
platform network library for handling all these diverse tasks. Java Network Program‐
ming exposes the power and sophistication of this library. This book’s goal is to enable

xiii
you to start using Java as a platform for serious network programming. To do so, this
book provides a general background in network fundamentals, as well as detailed dis‐
cussions of Java’s facilities for writing network programs. You’ll learn how to write Java
programs that share data across the Internet for games, collaboration, software updates,
file transfer, and more. You’ll also get a behind-the-scenes look at HTTP, SMTP,
TCP/IP, and the other protocols that support the Internet and the Web. When you finish
this book, you’ll have the knowledge and the tools to create the next generation of
software that takes full advantage of the Internet.

About the Fourth Edition


In 1996, in the first edition of this book’s opening chapter, I wrote extensively about the
sort of dynamic, distributed network applications I thought Java would make possible.
One of the most exciting parts of writing subsequent editions has been seeing virtually
all of the applications I foretold come to pass. Programmers are using Java to query
database servers, monitor web pages, control telescopes, manage multiplayer games,
and more, all by using Java’s native ability to access the Internet. Java in general and
network programming in Java in particular has moved well beyond the hype stage and
into the realm of real, working applications.
This book has come a long way, too. The fourth edition focuses even more heavily on
HTTP and REST. HTTP has gone from being one of many network protocols to almost
the network protocol. As you’ll see, it is often the protocol on which other protocols are
built, forming its own layer in the network stack.
There have been lots of other small changes and updates throughout the java.net and
supporting packages in Java 6, 7, and 8, and these are covered here as well. New classes
addressed in this edition include CookieManager, CookiePolicy, CookieStore,
HttpCookie, SwingWorker, Executor, ExecutorService, AsynchronousSocketChan
nel, AsynchronousServerSocketChannel, and more. Many other methods have been
added to existing classes in the last three releases of Java, and these are discussed in the
relevant chapters. I’ve also rewritten large parts of the book to reflect the ever-changing
fashions in Java programming in general and network programming in particular. I
hope you’ll find this fourth edition an even stronger, longer-lived, more accurate, and
more enjoyable tutorial and reference to network programming in Java than the pre‐
vious one.

Organization of the Book


Chapter 1, Basic Network Concepts, explains in detail what a programmer needs to know
about how the networks and the Internet work. It covers the protocols that underlie the
Internet, such as TCP/IP and UDP/IP.

xiv | Preface
The next two chapters throw some light on two parts of Java programming that are
critical to almost all network programs but are often misunderstood and misused: I/O
and threading. Chapter 2, Streams, explores Java’s classic I/O which—despite the new
I/O APIs—isn’t going away any time soon and is still the preferred means of handling
input and output in most client applications. Understanding how Java handles I/O in
the general case is a prerequisite for understanding the special case of how Java handles
network I/O. Chapter 3, Threads, explores multithreading and synchronization, with a
special emphasis on how they can be used for asynchronous I/O and network servers.
Experienced Java programmers may be able to skim or skip these two chapters. However,
Chapter 4, Internet Addresses, is essential reading for everyone. It shows how Java pro‐
grams interact with the Domain Name System through the InetAddress class, the one
class that’s needed by essentially all network programs. Once you’ve finished this chap‐
ter, it’s possible to jump around in the book as your interests and needs dictate.
Chapter 5, URLs and URIs, explores Java’s URL class, a powerful abstraction for down‐
loading information and files from network servers of many kinds. The URL class enables
you to connect to and download files and documents from a network server without
concerning yourself with the details of the protocol the server speaks. It lets you connect
to an FTP server using the same code you use to talk to an HTTP server or to read a file
on the local hard disk. You’ll also learn about the newer URI class, a more standards-
conformant alternative for identifying but not retrieving resources.
Chapter 6, HTTP, delves deeper into the HTTP protocol specifically. Topics covered
include REST, HTTP headers, and cookies. Chapter 7, URLConnections, shows you how
to use the URLConnection and HttpURLConnection classes not just to download data
from web servers, but to upload documents and configure connections.
Chapter 8 through Chapter 10 discuss Java’s low-level socket classes for network access.
Chapter 8, Sockets for Clients, introduces the Java sockets API and the Socket class in
particular. It shows you how to write network clients that interact with TCP servers of
all kinds including whois, dict, and HTTP. Chapter 9, Sockets for Servers, shows you
how to use the ServerSocket class to write servers for these and other protocols. Finally,
Chapter 10, Secure Sockets, shows you how to protect your client-server communica‐
tions using the Secure Sockets Layer (SSL) and the Java Secure Sockets Extension (JSSE).
Chapter 11, Nonblocking I/O, introduces the new I/O APIs specifically designed for
network servers. These APIs enable a program to figure out whether a connection is
ready before it tries to read from or write to the socket. This allows a single thread to
manage many different connections simultaneously, thereby placing much less load on
the virtual machine. The new I/O APIs don’t help much for small servers or clients that
don’t open many simultaneous connections, but they may provide performance boosts
for high-volume servers that want to transmit as much data as the network can handle
as fast as the network can deliver it.

Preface | xv
Chapter 12, UDP, introduces the User Datagram Protocol (UDP) and the associated
DatagramPacket and DatagramSocket classes that provide fast, unreliable communi‐
cation. Finally, Chapter 13, IP Multicast, shows you how to use UDP to communicate
with multiple hosts at the same time.

Who You Are


This book assumes you are comfortable with the Java language and programming en‐
vironment, in addition to object-oriented programming in general. This book does not
attempt to be a basic language tutorial. You should be thoroughly familiar with the
syntax of Java. You should have written simple applications. It also wouldn’t hurt if you’re
familiar with basic Swing programming, though that’s not required aside from a few
examples. When you encounter a topic that requires a deeper understanding for net‐
work programming than is customary—for instance, threads and streams—I’ll cover
that topic as well, at least briefly.
However, this book doesn’t assume that you have prior experience with network pro‐
gramming. You should find it a complete introduction to networking concepts and
network application development. I don’t assume that you have a few thousand net‐
working acronyms (TCP, UDP, SMTP, etc.) at the tip of your tongue. You’ll learn what
you need to know about these here.

Java Versions
Java’s network classes have changed a lot more slowly since Java 1.0 than other parts of
the core API. In comparison to the AWT or I/O, there have been almost no changes and
only a few additions. Of course, all network programs make extensive use of the I/O
classes and some make heavy use of GUIs. This book is written with the assumption
that you are coding with at least Java 5.0. In general, I use Java 5 features like generics
and the enhanced for loop freely without further explanation.
For network programming purposes, the distinction between Java 5 and Java 6 is not
large. Most examples look identical in the two versions. When a particular method or
class is new in Java 6, 7, or 8, it is noted by a comment following its declaration like this:
public void setFixedLengthStreamingMode(long contentLength) // Java 7
Java 7 is a bit more of a stretch. I have not shied away from using features introduced
in Java 7 where they seemed especially useful or convenient—for instance, try-with-
resources and multicatch are both very helpful when trying to fit examples into the
limited space available in a printed book—but I have been careful to point out my use
of such features.
Overall, though, Java’s networking API has been relatively stable since Java 1.0. Very
little of the post-1.0 networking API has ever been deprecated, and additions have been

xvi | Preface
relatively minor. You shouldn’t have any trouble using this book after Java 8 is released.
New APIs, however, have been somewhat more frequent in the supporting classes, par‐
ticularly I/O, which has undergone three major revisions since Java 1.0.

About the Examples


Most methods and classes described in this book are illustrated with at least one com‐
plete working program, simple though it may be. In my experience, a complete working
program is essential to showing the proper use of a method. Without a program, it is
too easy to drop into jargon or to gloss over points about which the author may be
unclear in his own mind. The Java API documentation itself often suffers from exces‐
sively terse descriptions of the method calls. In this book, I have tried to err on the side
of providing too much explication rather than too little. If a point is obvious to you, feel
free to skip over it. You do not need to type in and run every example in this book; but
if a particular method does give you trouble, you should have at least one working
example.
Each chapter includes at least one (and often several) more complex programs that
demonstrate the classes and methods of that chapter in a more realistic setting. These
often rely on Java features not discussed in this book. Indeed, in many of the programs,
the networking components are only a small fraction of the source code and often the
least difficult parts. Nonetheless, none of these programs could be written as easily in
languages that didn’t give networking the central position it occupies in Java. The ap‐
parent simplicity of the networked sections of the code reflects the extent to which
networking has been made a core feature of Java, and not any triviality of the program
itself. All example programs presented in this book are available online, often with
corrections and additions. You can download the source code from http://www.cafeau
lait.org/books/jnp4/.
I have tested all the examples on Linux and many on Windows and Mac OS X. Most of
the examples given here should work on other platforms and with other compilers and
virtual machines that support Java 5 or later. The most common reasons an example
may not compile with Java 5 or 6 are try-with-resources and multicatch. These examples
can easily be rewritten to support earlier Java versions at the cost of increased verbosity.
I do feel a little guilty about a couple of compromises necessitated by the needs of space
in a printed book. First, I rarely check preconditions. Most methods assume they are
passed good data, and dispense with null checks and similar principles of good code
hygiene. Furthermore, I have reduced the indentation to two characters per block and
four characters per continuation line, as opposed to the Java standard of four and eight,
respectively. I hope these flaws will not be too distracting. On the positive side, these
compromises have aided me in making this edition considerably shorter (by several
hundred pages) than the previous edition.

Preface | xvii
Conventions Used in This Book
Body text is Minion Pro, normal, like you’re reading now.
A monospaced typewriter font is used for:

• Code examples and fragments


• Anything that might appear in a Java program, including keywords, operators, data
types, method names, variable names, class names, and interface names
• Program output
• Tags that might appear in an HTML document

A bold monospaced font is used for:

• Command lines and options that should be typed verbatim on the screen

An italicized font is used for:

• New terms where they are defined


• Pathnames, filenames, and program names (however, if the program name is also
the name of a Java class, it is given in a monospaced font, like other class names)
• Host and domain names (www.hpmor.com)
• URLs (http://www.cafeaulait.org/slides/)
• Titles of other books (Java I/O)

Indicates a tip, suggestion, or general note.

Indicates a warning or caution.

Significant code fragments and complete programs are generally placed into a separate
paragraph, like this:
Socket s = new Socket("java.oreilly.com", 80);
if (!s.getTcpNoDelay()) s.setTcpNoDelay(true);

xviii | Preface
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
When code is presented as fragments rather than complete programs, the existence of
the appropriate import statements should be inferred. For example, in the preceding
code fragment you may assume that java.net.Socket was imported.
Some examples intermix user input with program output. In these cases, the user input
will be displayed in bold, as in this example from Chapter 9:
% telnet rama.poly.edu 7
Trying 128.238.10.212...
Connected to rama.poly.edu.
Escape character is '^]'.
This is a test
This is a test
This is another test
This is another test
9876543210
9876543210
^]
telnet> close
Connection closed.
Finally, although many of the examples used here are toy examples unlikely to be reused,
a few of the classes I develop have real value. Please feel free to reuse them or any parts
of them in your own code. No special permission is required. They are in the public
domain (although the same is most definitely not true of the explanatory text!).

Request for Comments


I enjoy hearing from readers, whether with general comments about this book, specific
corrections, other topics they would like to see covered, or just war stories about their
own network programming travails. You can reach me by sending an email to
[email protected]. Please realize, however, that I receive several hundred pieces of email
a day and cannot personally respond to each one. For the best chance of getting a per‐
sonal response, please identify yourself as a reader of this book. If you have a question
about a particular program that isn’t working as you expect, try to reduce it to the
simplest case that reproduces the bug, preferably a single class, and paste the text of the
entire program into the body of your email. Unsolicited attachments will be deleted
unopened. And please, please send the message from the account you want me to reply
to and make sure that your Reply-to address is properly set! There’s nothing quite so
frustrating as spending an hour or more carefully researching the answer to an inter‐
esting question and composing a detailed response, only to have it bounce because my
correspondent sent her feedback from a public terminal and neglected to set the browser
preferences to include her actual email address.
I also adhere to the old saying “If you like this book, tell your friends. If you don’t like
it, tell me.” I’m especially interested in hearing about mistakes. This is the fourth edition.
I’ve yet to make it perfect, but I keep trying. As hard as I and the editors at O’Reilly

Preface | xix
worked on this book, I’m sure there are mistakes and typographical errors that we missed
here somewhere. And I’m sure that at least one of them is a really embarrassing whopper
of a problem. If you find a mistake or a typo, please let me know so I can correct it. I’ll
post it on the O’Reilly website at http://oreil.ly/java_np_errata. Before reporting errors,
please check one of those pages to see if I already know about it and have posted a fix.
Any errors that are reported will be fixed in future printings.

Using Code Examples


This book is here to help you get your job done. In general, if this book includes code
examples, you may use the code in this book in your programs and documentation. You
do not need to contact us for permission unless you’re reproducing a significant portion
of the code. For example, writing a program that uses several chunks of code from this
book does not require permission. Selling or distributing a CD-ROM of examples from
O’Reilly books does require permission. Answering a question by citing this book and
quoting example code does not require permission. Incorporating a significant amount
of example code from this book into your product’s documentation does require per‐
mission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Java Network Programming, Fourth Edition,
by Elliotte Rusty Harold (O’Reilly). Copyright 2014 Elliotte Rusty Harold,
978-1-449-35767-2.”
If you feel your use of code examples falls outside fair use or the permission given here,
feel free to contact us at [email protected].

Safari® Books Online


Safari Books Online is an on-demand digital library that delivers
expert content in both book and video form from the world’s lead‐
ing authors in technology and business.
Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research, prob‐
lem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organi‐
zations, government agencies, and individuals. Subscribers have access to thousands of
books, training videos, and prepublication manuscripts in one fully searchable database
from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Pro‐
fessional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John
Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT
Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technol‐

xx | Preface
ogy, and dozens more. For more information about Safari Books Online, please visit us
online.

How to Contact Us
Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.


1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/java-network-prgamming.
To comment or ask technical questions about this book, send email to bookques
[email protected].
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments
Many people were involved in the production of this book. My editor, Mike Loukides,
got things rolling, and provided many helpful comments along the way that substantially
improved the book. Dr. Peter “Peppar” Parnes helped out immensely with Chapter 13.
The technical editors all provided invaluable assistance in hunting down errors and
omissions. Simon St. Laurent provided crucial advice on which topics deserved more
coverage. Scott Oaks lent his thread expertise to Chapter 3, proving once again by the
many subtle bugs he hunted down that multithreading still requires the attention of an
expert. Ron Hitchens shone light into many of the darker areas of the new I/O APIs.
Marc Loy and Jim Elliott reviewed some of the most bleeding edge material in the book.
Timothy F. Rohaly was unswerving in his commitment to making sure I closed all my
sockets and caught all possible exceptions, and in general wrote the cleanest, safest, most
exemplary code I could write. John Zukowski found numerous errors of omission, all
now filled thanks to him. And the eagle-eyed Avner Gelb displayed an astonishing ability
to spot mistakes that had somehow managed to go unnoticed by myself, all the other

Preface | xxi
editors, and the tens of thousands of readers of the first edition. Alex Stangl and Ryan
Cuprak provided further assistance with spotting both new and lingering mistakes in
this latest edition.
It isn’t customary to thank the publisher, but the publisher does set the tone for the rest
of the company, authors, editors, and production staff alike; and I think Tim O’Reilly
deserves special credit for making O’Reilly Media absolutely one of the best houses an
author can write for. If there’s one person without whom this book would never have
been written, it’s him. If you, the reader, find O’Reilly books to be consistently better
than most of the dreck on the market, the reason really can be traced straight back to
Tim.
My agent, David Rogelberg, convinced me it was possible to make a living writing books
like this rather than working in an office. The entire crew at ibiblio.org over the last
several years has really helped me to communicate better with my readers in a variety
of ways. Every reader who sent in bouquets and brickbats for previous editions has been
instrumental in helping me write this much-improved edition. All these people deserve
much thanks and credit. Finally, as always, I’d like to offer my largest thanks to my wife,
Beth, without whose love and support this book would never have happened.
—Elliotte Rusty Harold
[email protected]
July 5, 2013

xxii | Preface
CHAPTER 1
Basic Network Concepts

Network programming is no longer the province of a few specialists. It has become a


core part of every developer’s toolbox. Today, more programs are network aware than
aren’t. Besides classic applications like email, web browsers, and remote login, most
major applications have some level of networking built in. For example:

• Text editors like BBEdit save and open files directly from FTP servers.
• IDEs like Eclipse and IntelliJ IDEA communicate with source code repositories like
GitHub and Sourceforge.
• Word processors like Microsoft Word open files from URLs.
• Antivirus programs like Norton AntiVirus check for new virus definitions by con‐
necting to the vendor’s website every time the computer is started.
• Music players like Winamp and iTunes upload CD track lengths to CDDB and
download the corresponding track titles.
• Gamers playing multiplayer first-person shooters like Halo gleefully frag each other
in real time.
• Supermarket cash registers running IBM SurePOS ACE communicate with their
store’s server in real time with each transaction. The server uploads its daily receipts
to the chain’s central computers each night.
• Schedule applications like Microsoft Outlook automatically synchronize calendars
among employees in a company.

Java was the first programming language designed from the ground up for network
applications. Java was originally aimed at proprietary cable television networks rather
than the Internet, but it’s always had the network foremost in mind. One of the first two
real Java applications was a web browser. As the Internet continues to grow, Java is
uniquely suited to build the next generation of network applications.

1
One of the biggest secrets about Java is that it makes writing network programs easy. In
fact, it is far easier to write network programs in Java than in almost any other language.
This book shows you dozens of complete programs that take advantage of the Internet.
Some are simple textbook examples, while others are completely functional applica‐
tions. One thing you’ll notice in the fully functional applications is just how little code
is devoted to networking. Even in network-intensive programs like web servers and
clients, almost all the code handles data manipulation or the user interface. The part of
the program that deals with the network is almost always the shortest and simplest. In
brief, it is easy for Java applications to send and receive data across the Internet.
This chapter covers the background networking concepts you need to understand be‐
fore writing networked programs in Java (or, for that matter, in any language). Moving
from the most general to the most specific, it explains what you need to know about
networks in general, IP and TCP/IP-based networks in particular, and the Internet. This
chapter doesn’t try to teach you how to wire a network or configure a router, but you
will learn what you need to know to write applications that communicate across the
Internet. Topics covered in this chapter include the nature of networks; the TCP/IP layer
model; the IP, TCP, and UDP protocols; firewalls and proxy servers; the Internet; and
the Internet standardization process. Experienced network gurus may safely skip this
chapter, and move on to the next chapter where you begin developing the tools needed
to write your own network programs in Java.

Networks
A network is a collection of computers and other devices that can send data to and
receive data from one another, more or less in real time. A network is often connected
by wires, and the bits of data are turned into electromagnetic waves that move through
the wires. However, wireless networks transmit data using radio waves; and most long-
distance transmissions are now carried over fiber-optic cables that send light waves
through glass filaments. There’s nothing sacred about any particular physical medium
for the transmission of data. Theoretically, data could be transmitted by coal-powered
computers that send smoke signals to one another. The response time (and environ‐
mental impact) of such a network would be rather poor.
Each machine on a network is called a node. Most nodes are computers, but printers,
routers, bridges, gateways, dumb terminals, and Coca-Cola™ machines can also be no‐
des. You might use Java to interface with a Coke machine, but otherwise you’ll mostly
talk to other computers. Nodes that are fully functional computers are also called
hosts. I will use the word node to refer to any device on the network, and the word host
to refer to a node that is a general-purpose computer.
Every network node has an address, a sequence of bytes that uniquely identifies it. You
can think of this group of bytes as a number, but in general the number of bytes in an
address or the ordering of those bytes (big endian or little endian) is not guaranteed to

2 | Chapter 1: Basic Network Concepts


match any primitive numeric data type in Java. The more bytes there are in each address,
the more addresses there are available and the more devices that can be connected to
the network simultaneously.
Addresses are assigned differently on different kinds of networks. Ethernet addresses
are attached to the physical Ethernet hardware. Manufacturers of Ethernet hardware
use preassigned manufacturer codes to make sure there are no conflicts between the
addresses in their hardware and the addresses of other manufacturers’ hardware. Each
manufacturer is responsible for making sure it doesn’t ship two Ethernet cards with the
same address. Internet addresses are normally assigned to a computer by the organi‐
zation that is responsible for it. However, the addresses that an organization is allowed
to choose for its computers are assigned by the organization’s Internet service provider
(ISP). ISPs get their IP addresses from one of four regional Internet registries (the reg‐
istry for North America is ARIN, the American Registry for Internet Numbers), which
are in turn assigned IP addresses by the Internet Corporation for Assigned Names and
Numbers (ICANN).
On some kinds of networks, nodes also have text names that help human beings identify
them such as “www.elharo.com” or “Beth Harold’s Computer.” At a set moment in time,
a particular name normally refers to exactly one address. However, names are not locked
to addresses. Names can change while addresses stay the same; likewise, addresses can
change while the names stay the same. One address can have several names and one
name can refer to several different addresses.
All modern computer networks are packet-switched networks: data traveling on the
network is broken into chunks called packets and each packet is handled separately.
Each packet contains information about who sent it and where it’s going. The most
important advantage of breaking data into individually addressed packets is that packets
from many ongoing exchanges can travel on one wire, which makes it much cheaper to
build a network: many computers can share the same wire without interfering. (In
contrast, when you make a local telephone call within the same exchange on a traditional
phone line, you have essentially reserved a wire from your phone to the phone of the
person you’re calling. When all the wires are in use, as sometimes happens during a
major emergency or holiday, not everyone who picks up a phone will get a dial tone. If
you stay on the line, you’ll eventually get a dial tone when a line becomes free. In some
countries with worse phone service than the United States, it’s not uncommon to have
to wait half an hour or more for a dial tone.) Another advantage of packets is that
checksums can be used to detect whether a packet was damaged in transit.
We’re still missing one important piece: some notion of what computers need to say to
pass data back and forth. A protocol is a precise set of rules defining how computers
communicate: the format of addresses, how data is split into packets, and so on. There
are many different protocols defining different aspects of network communication. For
example, the Hypertext Transfer Protocol (HTTP) defines how web browsers and

Networks | 3
servers communicate; at the other end of the spectrum, the IEEE 802.3 standard defines
a protocol for how bits are encoded as electrical signals on a particular type of wire.
Open, published protocol standards allow software and equipment from different ven‐
dors to communicate with one another. A web server doesn’t care whether the client is
a Unix workstation, an Android phone, or an iPad, because all clients speak the same
HTTP protocol regardless of platform.

The Layers of a Network


Sending data across a network is a complex operation that must be carefully tuned to
the physical characteristics of the network as well as the logical character of the data
being sent. Software that sends data across a network must understand how to avoid
collisions between packets, convert digital data to analog signals, detect and correct
errors, route packets from one host to another, and more. The process is further com‐
plicated when the requirement to support multiple operating systems and heterogene‐
ous network cabling is added.
To hide most of this complexity from the application developer and end user, the dif‐
ferent aspects of network communication are separated into multiple layers. Each layer
represents a different level of abstraction between the physical hardware (i.e., the wires
and electricity) and the information being transmitted. In theory, each layer only talks
to the layers immediately above and immediately below it. Separating the network into
layers lets you modify or even replace the software in one layer without affecting the
others, as long as the interfaces between the layers stay the same.
Figure 1-1 shows a stack of possible protocols that may exist in your network. While
the middle layer protocols are fairly consistent across most of the Internet today, the
top and the bottom vary a lot. Some hosts use Ethernet; some use WiFi; some use PPP;
some use something else. Similarly, what’s on the top of the stack will depend completely
on which programs a host is running. The key is that from the top of the stack, it doesn’t
really matter what’s on the bottom and vice versa. The layer model decouples the ap‐
plication protocols (the main subject of this book) from the physics of the network
hardware and the topology of the network connections.

4 | Chapter 1: Basic Network Concepts


Figure 1-1. Protocols in different layers of a network

There are several different layer models, each organized to fit the needs of a particular
kind of network. This book uses the standard TCP/IP four-layer model appropriate for
the Internet, shown in Figure 1-2. In this model, applications like Firefox and Warcraft
run in the application layer and talk only to the transport layer. The transport layer talks
only to the application layer and the Internet layer. The Internet layer in turn talks only
to the host-to-network layer and the transport layer, never directly to the application
layer. The host-to-network layer moves the data across the wires, fiber-optic cables, or
other medium to the host-to-network layer on the remote system, which then moves
the data up the layers to the application on the remote system.

Figure 1-2. The layers of a network

For example, when a web browser sends a request to a web server to retrieve a page, the
browser is actually talking to the transport layer on the local client machine. The trans‐

The Layers of a Network | 5


Random documents with unrelated
content Scribd suggests to you:
the letter before him. He was uncertain whether he would open it or
not. Whatever it might contain would be unable to do away with the
fact which he had so recently witnessed with his own eyes.

No excuse could possibly explain away the disloyalty with which


she had treated him. It would be better, he thought, to return the
letter unopened. But then there might be something in it which in
future time he might regret not to have seen; some possible
palliation of her offence, some expression of regret or softening
explanation of the circumstances under which she had betrayed him.
And then Paul opened the letter, and read as follows:

"MY DEAR PAUL,--I do not think you will be surprised at what I am


about to tell you; and I try to hope that you will not be very much
annoyed at it. I knew that it must come very shortly, and I have
endeavoured as far as I could to prepare you for the news.

"The pleasant life which we have been leading for the last few
months, Paul--and I do not pretend to disguise my knowledge that it
has been pleasant to you, any more than I shrink from
acknowledging that it has been most delightful to me--has come to
an end, and we must never meet again. This should be no tragic
ending: there should be no shriek of woe or exclamations of
remorse, or mutual taunts and invectives. It is played out, that is all;
it has run down, and come naturally to a full-stop, and there is no
use in attempting to set it going again.

"I can understand your being horribly enraged when you first read
this, and using all sorts of strong language about me, and vowing
vengeance against me. But this will not last; your better sense will
come to your aid; in a very little time you will thank me for having
released you from obligations the fulfilment of which would have
brought misery on your life, and will thank me for having been the
first to put an end to an action which was very pleasant for the time
it lasted, but which would have been very hopeless in the future. For
my part, I don't reproach you, Paul, Heaven knows; I should be an
ingrate if I did.

"You have always treated me with the tenderest regard, and only
very lately you have done me the highest honour which a man can
do a woman, in asking her to become his wife. Don't think I treat
this offer lightly, Paul; don't think I am not keenly alive to its value,
as showing the affection, if nothing else, which you have, or rather
must have had, for me. Do not think that it has been without a
struggle that I have made up my mind to act as I am now doing, to
write the letter which you now read.

"But suppose I had said Yes, Paul; you know as well as I do the
exact position which I should have occupied, and the effect which
my occupancy of that position would have had on your future life. It
was not--I do not say this with any intention of wounding you--it
was not until you clearly found you could get me on no other terms
that you made me this offer; and though probably you will not allow
it even to yourself, you must know as well as I do, that after a while
you would find yourself tied to a wife who was unsuited to you in
many ways, and by marrying whom you had alienated your family
from you, and disgraced yourself in the opinion of that world which
you now profess to despise, but of whose verdict you really stand in
the greatest awe.

"And then, Paul, it would be one of two things: either you would
hold to me with a dogged defiance, which is not part of your real
nature, but which, under the circumstances, you would cultivate,
feeling yourself to be a martyr, and taking care to let me know that
you felt it--you will deny all this, Paul, but I know you better than
yourself; or you would feel me to be a clog upon you, and leave me
for the society in which you could forget that, for the mere
indulgence of a passing passion, you had laid upon yourself a
burden for life.
"What but misery could come out of either of these two results?
Under both of them we should hate each other; for I confess I
should not be grateful to you for the enforced companionship which
the former presupposes; and under the latter I should not merely
hate you, but in all probability should do something which would
bring dishonour on your name. You see, I speak frankly, Paul; but I
do so for the best. If you had been equally frank with me, I could
have told you long since, at the commencement of our
acquaintance, of something which would have prevented our ever
being more to each other than the merest acquaintances. You told
me your name was Paul Douglas; you disguised from me that it was
Paul Derinzy. Had I known that, I would have then let you into a
secret; I would have told you that I too had in a similar manner
been deceiving you by passing under the name of Fanny Stafford,
whereas my real name is Fanny Stothard.

"Does not that revelation show you what is to come, Paul? Do you
not already comprehend that I am the daughter of a woman who
holds a menial position in your father's house, and that this fact
would render wider yet the chasm which yawns between our
respective classes in society? You do not imagine that your mother
would care to recognise in her son's wife the daughter of her
servant, or that I should particularly like to become a member of a
family in which my cousin's waiting-woman is my own mother.

"I ascertained this fact in sufficient time to have made it, if I had
so chosen, the ground for putting an end to our intimacy, and my
reason for writing this letter; but I preferred not to do so, Paul. I
have put the matter plainly, straightforwardly, and frankly; and I will
not condescend to ride off on a quibble, or to pretend that I have
been influenced by your want of confidence in withholding your
name. You will see--not now, perhaps, but in a very little time--that I
have acted for the best, and will be thankful to me for the course
which I have taken.
"And recollect, Paul, the breach between us must be final--it must
be a clean cut; and you must not think, even after it has been made,
that there are any frayed and jagged points left which are capable,
at some time or another, of being reunited. We have seen each other
for the last time; we have parted for ever. There must be no
question of any interview or adieu; we are neither of us of such
angelic tempers that we could expect to meet without reproaches
and high words; and I, at all events, should be glad in the future to
recall the last loving look in your eyes, and the last earnest pressure
of your hand.

"And that mention of the future reminds me, this letter is the last
communication you will receive from me; and when you have
finished reading it, you must look upon me as someone dead and
passed away. If by chance you ever meet me in the street, you must
look upon me as the ghost of someone whom you once knew, and
forbear to speak to me. It will not be very difficult to imagine this;
for, God knows, I shall be no more like the Fanny Stafford whom you
have known than the Fanny Derinzy you would have made me. No
matter what I am, no matter what I may become, you will have
ceased to have any pretext for inquiring into my state; and I
distinctly forbid your attempting to interfere with me in the slightest
degree. Does that sound harsh, Paul? I do not mean it so; I swear I
do not mean it so. If you knew--but you do not, and never shall. You
are hot and impetuous and weak; I am cool and clear-brained and
strong-minded: you look only at the present; I think for the future.
You will repeat all this bitterly, saying that I am right, and that my
conduct plainly shows I know exactly how to describe myself; I know
you will, I can almost hear you say it. I half wish I could hear you
say anything, so that I could listen to your dear voice once again;
but that could never be.

"Goodbye, Paul! At some future time, not very long hence, when
all this has blown over, and you are in love with, and perhaps
married to, someone else, you will acknowledge I was right, and
think sometimes not unkindly of me. But I shall never think of you
again. Once more, goodbye, Paul! I should like to say, God bless
you! if I thought such a prayer from me would be of any use."

Paul Derinzy read this letter through twice, and folded it up and
placed it in his pocket. Ten minutes afterwards the writing-room bell
rang violently, and the servant, on answering was surprised to find
an old gentleman kneeling on the floor, and bending over the
prostrate body of Mr. Derinzy, whose face was very white, whose
neck-cloth was untied, and who the old gentleman said was in a fit.

CHAPTER XXIX.

RELENTING.

When George Wainwright left the presence of the strange old


German doctor, upon whom he had looked with an almost awful
anxiety, a half-superstitious hope, it was with an acute sense of
disappointment, such as had rarely stung the young man's ordinarily
placid and well-disciplined mind. He had the profoundest respect for
his father's opinion, the most implicit reliance on his father's
judgment; and from the sentence which pronounced the case of
Annette hopeless, except under those conditions whose fulfilment he
now found it impossible to procure, he never thought of appealing.
His father--of whose science in theory, of whose skill in practice, his
own experience had offered him innumerable instances--had told
him, with genuine concern and with true sympathy, rather than the
more formal paternal manner it was the doctor's custom to exhibit
towards his son, that this one only hope existed, this solitary chance
presented itself. He had caught at the hope; he had endeavoured to
reduce the chance to practice; and he had failed.

There was bitterness, there was agony, in the conviction, such as


had never fallen to the lot of George Wainwright before, though life
had brought him some of those experiences which Mr. Dunlop was
wont to designate as "twisters" too. But then so much depends on
the direction, the strength, and the duration of the "twist," and there
are some so easily gotten over.

This, however, was not one of them; and George's heart was
sorely wrung. The pain was directed cunningly, and strongly applied,
and as for its duration--well, George believed, as we all believe when
suffering is very keen and very fresh, that it was going to be
everlasting. It couldn't be otherwise, indeed, in the sense in which
"everlasting" applies itself to this mortal individual life; for did it not
mean that the woman he loved, the one woman he really loved and
longed for, was doomed for her term of terrestrial existence to the
saddest of all destinies, which included utter separation from him?
While they both lived, if that fiat should remain unaltered, how
should his sorrow be less than everlasting? If it be true that there
are certain kinds of trouble, and sharp trouble too, to which men
and women do become accustomed, of a surety this was not one of
them, but trouble of a vital kind, full of murmuring, of wretchedness,
and regret. So long as they both should live--he a sane man, loving
this periodically-insane woman as he loved her, with a strong
passionate attachment, by no means deficient in the conservative
element of intellectual attraction--whence should the alleviation
come?

George Wainwright liked pain as little as most men like it; and as
he turned his face towards England, discomfited and utterly
downcast, he felt, with a sardonic morbidity of feeling, that he would
not be disinclined now to exchange his capacity of suffering and his
steadiness of disposition for the volage fickleness which he was
accustomed to despise in many of his associates. If he could get
over it, it would be much better for him, and no worse for her, he
thought; but the next true and fine impulse of his nature rebuked
the foregoing, and made him prize the sentiments which had come
to ennoble his life, to check its selfishness and dissipate its ennui,
though by the substitution of pain. And for her? He had seen so
plainly, so unmistakably the difference in Annette, the new element
of hope, anticipation, and enjoyment which her affection for him had
brought into her hitherto darkened life, that the utmost exertion of
his common sense failed to make him believe she would be the
better for the complete severance between them which reason
dictated to him ought to be the upshot of the failure of his
enterprise.

"It is better to have loved," he repeated to himself, as he sat


moodily in the railway-carriage on his return journey, unheeding
alike the trimly-cultivated country through which he was passing,
and the profusion of flimsy literature, journalistic and other, with
which the cushions were strewn--"it is better to have loved----" And
then he thought, "She is not lost. She lives, and I can see her. I may
cheer and alleviate her life, though it may never be blessed with
union. When the dark days come, they will be less dark to her,
because when she emerges into light again, it will be to find me;
and at her best and brightest--ah, how good and bright that is!--she
will be happier and better because of me. Good God! am I so weak
and so selfish that I cannot accept what there is in this of blessing,
without pining for that which can never be?"

Thus, striving manfully with his bitter disappointment, and


strengthening himself with earnest and manly resolutions, George
Wainwright returned to England. Perhaps the sharpest pang he felt,
sharper even than that with which he had heard Dr. Hildebrand's
decided refusal and had obeyed his peremptory dismissal, was
caused by the momentary shrinking from the sight of Annette, which
made itself felt as he approached the place of her abode. At first
there had been wild, reckless longing to see her, longing in which
love was intensified by pity and sharpened by grief; then came this
instinctive dread and lingering. He had left her with so much hope,
so much energy, such strong conviction; he was returning with none
of these. He was returning to look in the dear face so often
overhung with the mysterious fitful veil of insanity, and to be forced
to feel that it could never be given to mortal hand to lift that veil,
and to throw it aside for ever. And though his first impulse had been
to hasten back to England with all possible speed, when he arrived
in London he lingered and hesitated about announcing himself at the
residence of the Derinzys.

Should he go to his father's chambers at the Albany in the first


instance, and tell him how his hopes had collapsed?--not because,
as Dr. Wainwright had supposed, the eccentric and famous German
savant was dead, but because the rampant vitality of professional
jealousy had utterly closed his heart to George's pleadings, and even
obscured the ambition to make one cure more, which, to the joy of
many a heart, has been found too strong to be resisted by more
than one celebrated physician en retraite. Yes, he would see his
father in the first instance; it would give him nerve. Indeed, he
ought to do so for another reason.

He must henceforth be doubly careful in his dealings with Annette;


he who--it would be absurd to disguise his knowledge of the fact--
had assumed greater importance in her life than any other being,
who noted and managed her, and swayed her temper and her
fancies as no one beside; and this was exactly the conjuncture in
which the advice, the guidance, of the physician charged with her
case would be indispensable. George would obtain it and obey it to
the utmost. Supposing his father, in the interest of his patient and
his son, were to pronounce that under the circumstances it would be
advisable that the young people should not meet, could George
undertake to obey the behests of the physician or the counsel of the
father? This was a difficult question. In such a case he would appeal
promptly to that excellent understanding, that taken-for-granted
equality which had subsisted between him and Dr. Wainwright, and
put it to him that he was prepared to sacrifice himself for the welfare
of the girl, and to lend to her blighted life all the alleviation which his
friendship and his society could afford, while strictly guarding himself
from the avowal of any warmer feeling.

Assisted by these resolutions, and perhaps not quite unconscious


that he would have been slow to credit any other person who might
have formed them with the courage to maintain them, George
Wainwright presented himself before his father. The Doctor received
him kindly, and listened to the account of his fruitless journey
without any evidence of surprise.

"I am glad the old man is still living," said Dr. Wainwright, when
George had finished his story; "but sorry to find he is not so great a
man as I had believed him to be. No great man allows a personal
feeling, prejudice, or pique to interfere with his theories or hamper
his actions. The idea of his declining such a case because I had been
unsuccessful with the patient! Why, that ought, even according to
his own distorted notions, to be the strongest reason for his going at
it with a will. However," and the "mad doctor" laughed a low laugh
and rubbed his hands gently together, "there are queer freaks and
cranks of the human mind to be seen outside of lunatic asylums."

George was a little impatient of his father's attention being rather


given to Dr. Hildebrand than to his feelings under the circumstances,
and he recalled it by the abrupt question:

"What is to be done now?"

"Nothing," replied Dr. Wainwright; "nothing in the sense of cure,


nothing additional in the way of treatment."

"May I--may I safely continue to see her?"

The son knew well how thoroughly, under the habitual


professional composure of his manner, the father comprehended and
felt the deep importance of the reply he was about to make.
"The question of safety," he said, "mainly concerns you. Do you
think you would do wisely in continuing to seek the society of this
poor girl, feeling as you do towards her, and knowing she cannot be
your wife?"

"My dear father," replied George with deliberation, "I do not think,
I do not say it would be wise; I only say it is one of those foolish
things which are inevitable. Put me aside in the matter, and tell me
only about her."

"Then," said the Doctor, "I have no hesitation in saying I do not


think you can harm her. Your society cheers and amuses her. In her
state there is little danger of the awakening of any deep and
permanent feeling. Should such a danger arise, I should be sure to
perceive and prevent it."

After a long conversation, the father and son parted. Dr.


Wainwright felt considerable regret that George's feelings should be
thus involved; but he reasoned upon the case, according to his lights
and convictions, and did not exaggerate its importance, believing
that his son was not the sort of man to make himself perfectly
uncomfortable about any woman whom it was quite impossible he
should marry. He thought about the whole party after his son had
left him--of Annette with liking and compassion; of George with
affection, and a recognition of the difference which existed between
his own mind and his son's; and of the Derinzys with supreme
contempt. Perhaps, in the long list of his friends and patients, there
were not to be found two individuals whom Dr. Wainwright--a man
not given to venerating his fellow-creatures--more thoroughly
despised than Captain and Mrs. Derinzy. And then he turned to his
books again, and forgot them.

From his father's chambers in the Albany, George Wainwright went


direct to the Derinzys' house. Mrs. Derinzy was at home, as was Miss
Annette; but Mr. Wainwright could not on this occasion have the
pleasure of seeing the Captain. So far, everything was propitious to
that gentleman's wishes; and he entered the small back drawing-
room, which no one but a house-agent or an upholsterer would have
called a boudoir, where. Annette was usually to be found, lounging
near a flower-crowded balcony, with the feeling of joy at seeing her
again decidedly predominant. He was philosophic, but he was
something more than a philosopher; and this afflicted girl had
become inexpressibly dear to him, had inspired him with a love in
which selfishness had a strangely small share.

Annette was in her usual place, and she rose to meet George with
an expression of simple unaffected pleasure. Mrs. Derinzy, who was
also in the room, greeted him with cold politeness. She was not so
foolish as to persist in believing she could have carried her design to
a successful issue in any case; but she vas quite sufficiently unjust to
resent George's influence over Annette, though she knew it had
never been employed against her, and though she felt a malicious
satisfaction in contemplating the hopelessness of the affair.

"If anyone would marry an insane woman, knowing all about her,
it certainly would not be a mad doctor's son," thought Mrs. Derinzy,
and was pleased to feel that other people's plans had to "gang a-
gley" as completely as her own.

George took Mrs. Derinzy's manner very calmly and contentedly.


He did not care about Mrs. Derinzy or her manner. He was thinking
of Annette, and reading the indications of health, or the opposite, in
her pleased agitated face.

"Where have you been, and why have you stayed away so long?"
was the first address to George; and she could hardly have selected
one more embarrassing. But he got out of the difficulty by the plea
which is satisfactory to every woman except one's wife--possibly
because she alone can estimate its real value--the plea that
"business" had taken him on a flying tour to Germany. He
entertained her with an account of his travels, and had at least the
satisfaction of seeing her brighten up into more than her customary
intelligence, and assume an expression of happiness which had been
singularly wanting in her sweet young face when he had first seen it,
and which he believed he was the only person who had ever
summoned up. It was not difficult for George, sitting near the
handsome girl, so bright and so gentle for him alone, in the pleasant
hush of the refined-looking room, to persuade himself that such a
state of things would satisfy him, and be the very best possible for
her. It was not difficult for him to forget that the Derinzys were not
habitual inhabitants of London; and that if his relations with Annette
were destined to assume no more definite form, he could have no
valid excuse for presenting himself at Beachborough without the
invitation which Mrs. Derinzy's demeanour afforded him no hope of
obtaining.

But George's delusive content was not destined to be lasting. At a


break in the conversation, which, with the slightest possible
assistance from Mrs. Derinzy, he was carrying on with Annette, he
asked the elder lady for news of Paul, adding that he had not written
to his friend during his absence, and had not yet had time to apprise
him of his return.

"We have seen hardly anything of Paul of late," said Mrs. Derinzy
in a tone of strong displeasure. "My residence in London has not
procured me much of the society of my son; and since you left town,
I cannot say we know anything about him."

"This looks badly," thought George. "With all his determination to


resist his mother, Paul would not neglect her if things were not going
ill with him. I must see to him."

That visit was memorable, and in more ways than one. It was the
last which George Wainwright made to Mrs. Derinzy in the character
of a mere friendly acquaintance, and it confirmed him in his belief,
as full of fear as of hope, that Annette loved him.
His absence had not been of long duration, but it sent him back
with renewed zest to his painting, his books, and his music, and
there was a strong need within him of a little rest and seclusion. He
felt he must "think it out;" not in foreign scenes or amid distractions,
but thus, amid his actual present surroundings, in the very place
where he should have to "live it down." So it came to pass that he
did not forthwith go in search of Paul, but contented himself with
writing him a note and bidding him come to him--a summons which,
to George's surprise, his friend neither responded to nor obeyed. His
leave had not expired, and a few days of the solitude his soul loved
were within his reach.

Beyond his customary evening visit to Madame Vaughan--in whose


appearance he noted a change which aroused in him apprehensions
shared by her attendants and the resident doctor, but whose
intelligence was even more than usually bright and sympathetic,
though her delusion remained unchanged--George Wainwright went
nowhere and saw no one for three days. At the end of that time his
seclusion was interrupted by an unexpected visitor.

It was his father. And his father had so manifestly something


important to communicate, that George, whose sensitive
temperament had one feminine tendency, that which renders a man
readily apprehensive of ill news, started up and said:

"There is something wrong! Miss Derinzy----"

"Sit down, George, and keep quiet," said the Doctor kindly,
regarding his son's impetuosity with a good-natured critical
amusement. "There's nothing in the least wrong with Miss Derinzy;
and though a rather surprising event has happened, it is not at all of
an unpleasant nature--indeed, quite the reverse. You have made a
conquest, a most valuable conquest, my dear boy."

"Who is she?" said George, with a not very successful smile. "Have
you come to propose to me on the part of a humpy heiress?"
"Not in the least. There is no she in the case. You have made a
conquest of old Hildebrand, and its extent and validity are tolerably
clearly proved, I think, considering that he has gotten rid of an
antipathy of long standing, surmounted a deeply-rooted prejudice.
He has actually written to me--to me, the man who, in his capacity
of doctor and savant, he holds in abhorrence, who, I am sure, he
sincerely believes to be a quack and an impostor. He has written me
a most friendly original letter, a curiosity of literature even in
German; but he thought proper to air his English, and the production
took me nearly an hour to read."

Dr. Wainwright took a letter out of his pocket as he was speaking--


a big square letter, a sheet of coarse-grained, thin, blue paper,
sealed with a blotch of brown wax, and directed in a most crabbed
and unmanageable hand, the address having been subsequently
sprinkled, with unnecessary profusion, with glittering sticky sand.
George glanced at the document with anxious eyes.

"I don't intend to inflict the reading of it on you," continued the


Doctor. "I can tell you its contents in a few words. Dr. Hildebrand
consents to undertake the treatment of Miss Derinzy on your
account, provided the young lady be formally confided to his care by
her relatives, on my authorisation; that I state in writing and with
the utmost distinctness all the particulars and the duration of the
case, and acknowledge that it surpasses my ability to cure it. In
addition, I am to undertake to publish in one of the medical journals
an account of the case--supposing Miss Derinzy to be cured, of
which Hildebrand writes as a certainty--and give him all the credit."

George had punctuated his father's calm speech with various


exclamations, of which the Doctor had not taken any notice; but
now he said:

"My dear father, this is a wonderful occurrence; but you could not
consent to such conditions."
"Indeed! and why not? Do you think I ought to be as foolish and
as egotistical as that incomparably sagacious and skilful Deutscher,
whose conduct I reprobated so severely, and whom you apparently
expect me to imitate? No, George; professional etiquette isn't a bad
thing in its way, but it should not be permitted to override common
sense, humanity, and one's simple duty. If some small bullying of
me, if some ludicrous shrill crowing over me, enter into the scheme
of this odd-tempered sage, so be it. He shall make the experiment;
and if he succeed, nobody except yourself will be more heartily
rejoiced than the doctor who failed."

George shook hands with his father silently, and there was a brief
pause. Dr. Wainwright resumed:

"This queer old fellow assigns the very great impression which you
produced upon him as the cause of his change of mind. You are a
fine fellow, it appears; a young man of high tone and of worthy
sentiments, a young man devoid of the narrowness and coldness of
the self-seeking and gold-loving English nation. A pang, it seems,
entered the breast of the learned Deutscher when he reflected that
on an impulse--whose righteousness he defends, without the
smallest consideration that his observations are addressed to me--he
refused to extend the blessing of his unequalled service and
unfailing skill to an afflicted young lady of whose amiability it was
impossible for him any doubt to entertain, considering that she was
by so superior a young man beloved. Under the influence of this
pang of conscience, stimulated no doubt by the wish to achieve a
great success at my expense, Hildebrand begs to be put in
communication with you, and with the friends of the so interesting
young lady, and promises all I have already told you. And now, we
must act on this without any delay. A little management will be
necessary as regards the affectionate relatives of Miss Derinzy."

George was a little surprised at his father's tone. It was the first
time he had departed so far from his habitual reticence in anything
connected with professional matters. But a double motive was now
influencing the Doctor: interest of a genuine nature in his son's love-
affair, and the true anxiety for the result of a scientific experiment
which is inseparable from real knowledge and skill. The family
politics of the Derinzys were to be henceforth openly discussed
between Dr. Wainwright and his son.

"You do not suppose they will make any objection? They can have
no wish but for her recovery."

"I should have said that her recovery would not have concerned or
interested them particularly a short time ago," said Dr. Wainwright
calmly. "When they were not yet aware that their plan for marrying
their niece to their son could not be carried into effect--the money in
Paul's possession, and their own claims upon it amply satisfied, as of
course they would have been--I don't think the Captain, at all
events, would have concerned himself much further about the
condition of his daughter-in-law, or cared whether Paul's wife were
mad or sane. But all this is completely changed now, by Paul's
refusal to marry his cousin. The girl's restoration to perfect sanity is
the sole chance for the Derinzys getting hold of any portion of her
property, by testamentary disposition or otherwise; as on her coming
of age, the circumstances must, of course, be legally investigated."

"Would not Captain Derinzy be Annette's natural heir in the event


of her death?" asked George.

"No," replied the Doctor. "I see you are surprised; and I must let
you into a family secret of the Derinzys in order to explain this to
you. They have some reason for believing, for fearing, that Miss
Derinzy's mother is living. At another time I will tell you as much as I
know of the story; for the present this is enough to make you
understand the pressure which can be brought to bear, in order to
induce Captain and Mrs. Derinzy to follow out the instructions I
mean to give them."
"I understand," said George. "And now tell me what you intend to
advise. I suppose I am not to appear in this at all?"

"Not at present, certainly. I should not fancy the Captain and Mrs.
Derinzy knowing anything about your flight in search of old
Hildebrand. It is preferable that I should gravely and authoritatively
declare their niece to require the care of this eminent physician, of
whose competence I am thoroughly assured; and I shall direct that
Miss Derinzy be placed under his charge as authoritatively, but also
in as matter-of-course a fashion, as if it were merely a case of 'the
mixture as before.' There is no better way of managing people than
of steadily ignoring the fact that any management is requisite, and
also that remonstrance is possible. I shall adopt that course, and I
answer for my success. Miss Derinzy shall be under Dr. Hildebrand's
care in a week from this time; and I trust the experiment will be
successful."

"Are you going there now?"

"I am going there at once."

"I should like to go with you--not into the house, you know--so as
to know as soon as possible."

"Very well; come along, then. You can sit in the carriage, while I
go in and see my patient. Be quick; we can discuss details on our
way."

Two minutes more saw George Wainwright seated beside his


father in one of the least pretentious and best-appointed broughams
in London, to the displacement of sundry books and pamphlets, the
indefatigable Doctor's inseparable companions.

"You are acquainted with Mrs. Stothard, I presume," said the


Doctor, "and aware of her true position in the family: partly nurse,
partly companion, partly keeper to my patient."
George winced as his father completed this sentence, but
unperceived.

"Yes," he replied, "I do know her: a disagreeable, designing,


unpleasant person--strong-minded decidedly."

"Strong-bodied too; and needing to be so sometimes, I am sorry


to say."

George winced again.

"I shall give my directions to her. She must accompany Miss


Derinzy. She is faithful to the girl's interest; and would be a cool and
deliberate opponent of the Derinzys if there were any occasion for
open opposition, which there will not be."

"She is of a strange, concentrated nature," said George. "I don't


think she loves Annette."

"Oh dear no; I should say not," rejoined the Doctor. "I fancy she
does not love anybody--not even herself much--and cares for
nothing in the world beyond her interests; but she is wise enough to
know they will be best served by her fulfilment of her duty, and
practical enough to act on the knowledge--not an invariable
combination. She has behaved well in Miss Derinzy's case; and she
may always be relied upon to do what I tell her."

"Should no one else accompany Annette?"

"Well, yes; I think I shall send one of our own people--Collis is a


capital fellow, as good as any courier at travelling, and can be
trusted not to talk when he comes back. Yes, I'll send Collis," said
the Doctor, in a tone of decision.

George approved of this. Collis was an ally of his. Collis was a


special favourite with Madame Vaughan; and in his occasional
absences, George always left him with a kind of additional charge of
corridor No. 4.

"That seems a first-rate arrangement, sir," said he; "I hope you
may find you can carry it out in all particulars."

Dr. Wainwright did not reply; he merely smiled. He was


accustomed to carry out his arrangements in all particulars. They
were nearing their destination.

"I wonder how Annette will take it: whether she will object--will
dislike it very much?" George said uneasily.

His father turned towards him, and at the same minute half rose,
for they had arrived at the door of the Derinzys' house.

"She will take it very well, she will not object," he said
impressively; "for I am going to try an experiment on my own part. I
mean to tell her the whole truth about herself."

He stepped out of the carriage and went into the house.

During Dr. Wainwright's absence, George recalled every incident of


his interview with Dr. Hildebrand with mingled solicitude and
amusement. The caprice and inconsistency of the old man were, on
the one hand, alarming; but they were, as George felt,
counterbalanced by a certain conviction of ability, of knowledge, an
entire and cheerful confidence in his skill, which he irresistibly
inspired. If, indeed, it should be well-founded confidence; if
incidentally Annette should owe her restoration to perfect mental
health to the man who loved her; if the result of this should be their
marriage under circumstances which should no longer involve a
defiance of prudence--then George felt that he should acknowledge
there was more use in living, more good and happiness in this
mortal life, than he had hitherto been inclined to believe in.
He glanced occasionally up at the windows; not that he expected
to see Annette, who invariably occupied the back drawing-room.

Presently the white-muslin blinds were stirred, and Dr. Wainwright


appeared at one of the windows, and in the opposite angle Captain
Derinzy, who, to judge by the expression of his countenance, was, if
not pronouncing his favourite ejaculation, "Oh, damn!" at least
thinking it. It was quite plain the conference was not pleasant; and
George could see his father's face set and stern. After a few minutes
the speakers moved away from the window; and then a quarter of
an hour elapsed, during which George found patient waiting very
difficult. At the end of that time Dr. Wainwright reappeared, and got
into the carriage.

"Well," questioned George, "what did Captain Derinzy say?"

"Never mind what Captain Derinzy said. He is a fool, as well as


one or two other things I could name, if it were worth while. But it
isn't. He must do as he is bid; and that is all we need care about. I
have seen Mrs. Derinzy and Mrs. Stothard, and settled it all with
them. Miss Derinzy will be ready to start in three days from the
present."

"You did not see Annette?"

"No, of course not. My interview with her will not be an affair of


twenty minutes. I shall see her early to-morrow morning, and make
it all right. And now, my dear boy, I am going to set you down. I
have given as much time to the affaire Derinzy as I can spare at
present. I shall write to Hildebrand to-night, and you had better
write to him too, in your best German and most sentimental style.
Goodbye for the present."

Dr. Wainwright pulled the check-string, the carriage stopped, and


George was deposited at a street-corner. His father was immersed in
a pamphlet before he was out of sight.
George saw Annette once, by special permission of Dr.
Wainwright, during the three days which sufficed for her
preparations. He had been strictly enjoined to avoid all agitating
topics of conversation, and was not supposed by Annette to be
acquainted with the facts of the case, or the nature of the interview
which had taken place as arranged by Dr. Wainwright. While
studiously obeying his father's injunctions, George watched Annette
narrowly as he cautiously spoke of the Doctor, towards whom she
had never displayed the smallest liking or confidence, and he
perceived that the disclosures which had been made to her had
already produced a salutary effect. There was less versatility in her
manner, and more cheerfulness, and she spoke voluntarily and with
grateful appreciation, although vaguely, of Dr. Wainwright. She
alluded freely to her projected journey; and it was rather hard for
George to conceal that he had some previous knowledge on the
subject. Her manner, modest and artless as it was, could not fail to
be interpreted favourably to himself by the least vain of men; and
when the moment of parting came, it needed his strong sense of the
all-importance of discretion to enable him to restrain his emotion, to
conceal his consciousness of the impending crisis. When the
interview was over, and George had taken leave of Annette, when he
went away with the memory of a sweet, tranquil, sane smile, as the
last look on her face, he was glad.

No mention had been made by Mrs. Derinzy of her son, by


Annette of her cousin, and George had been so absorbed in the
interest of this strange and exciting turn of affairs, that he had not
thought of his friend. But when he had, from a point of view whence
he was not visible, watched the departure of Miss Derinzy, Mrs.
Stothard, and Annette's maid, under the charge and escort of the
trustworthy and carefully-instructed Collis, as he turned slowly away
from the railway-station when the tidal-train had rushed out of sight,
he said to himself:

"Now I must go and look after Paul."


CHAPTER XXX.

DAISY'S RECANTATION.

There was no doubt about it, Paul was very ill indeed. The doctor,
when he came, pronounced the young man to be in a very critical
state, and gave it as his opinion that an attack of brain-fever was
impending. This confidence was given to George, for whom Paul's
landlady had sent at once, immediately on her lodger being brought
home. The doctor--who was no other than little Doctor Prater, the
well-known West-End physician, who is looked upon, and not
without reason, as the medical ami des artistes--took George aside,
and probably without knowing it, put to him as regards Paul the
same question which Doctor Turton asked Oliver Goldsmith,
"Whether there was anything on his mind?" The response was pretty
much the same in both cases. George shook his head and shrugged
his shoulders, and admitted that his friend had been "rather upset
lately."

"Ah, my dear sir," said the little doctor, "not my wish to pry into
these matters; man of the world, see so much of this sort of thing in
the pursuance of a large practice, could tell at once that our poor
friend had some mental shock. Lady, I suppose? Ah well, must not
inquire; generally is at his time of life; later, digestion impaired, bank
broken; but in youth generally a lady. I am afraid he is going to be
very bad; at present agrotat animo magis quam corpore, as the
Latin poet says; but he will be very bad, I have not the least doubt."
"It's a bad business," said George dolefully, "a very bad business.
He ought to be nursed, of course; and though I have heard him
speak of the woman of the house as kind and attentive and all that,
I don't know that one could expect her to give her time to attend to
a sick man."

"Our young friend will require a good deal of attention, my dear


sir," said the little doctor; "for night-work, at all events, he must
have some professional person. What did you say our young friend's
name was? Mr. Derinzy. Ah, the name is familiar to me as--yes, to be
sure, great house in the City, millionaire and that kind of thing; and
your name, my dear sir?"

"My name is Wainwright," said George, smiling in spite of himself


at the little man's volubility.

"Wainwright! not son of---- My dear sir, I am glad to make your


acquaintance; one of the brightest ornaments of our profession; any
care that I should have bestowed on this interesting case will be
redoubled now that I know that our poor young friend here is a
friend of yours. You will kindly take care that these prescriptions are
made up at Balsam and Balmelow's, if you please; must have the
best of drugs in these cases, and no other house is so much to be
depended upon. Now I must run away; I will look in again in the
evening; and during my absence I will make arrangements for the
night-nurse. The attendance in the daytime I must look to you to
provide. Good-day, my dear sir." And wringing George's hand
warmly, the little man trotted off, jumped into his brougham, and
was driven away to inspect, prescribe for, and chatter with a dozen
other cases within the next few hours.

George sat down by the bedside and bent over its occupant, who
was tossing restlessly from side to side, gazing about him with
vacant eyes, and muttering and moaning in his delirium. What were
the words, incoherent and broken, issuing from his parched lips? "My
darling, my darling, stay by me now--no more horrible parting--
never again that scornful look! Daisy, say you did not mean it when
you wrote; say there is no one else--to-morrow, darling, in the old
place--come and tell me your mind--my wife, my darling!"

These words were uttered with such intensity of earnestness--and


although Paul's glance was never settled, his eyes roving here and
there as he tossed and flung about his arms on the bed, there was
such a piteous look in his face--that George Wainwright's emotion
overcame him, and two big tears rolled down his cheeks.

"This will never do," said he, brushing them hastily; "it is as I
thought, and that little doctor was right in his random hit. This affair
with the girl has assumed proportions which I never suspected. Poor
dear Paul used to make it out bad enough; but I had no notion that
it had come to any crisis, or indeed, if it had, that he would suffer
from it in this way. Now what is to be done? I think the first thing
will be to see this young lady, and bring her to her bearings. If she
has thrown Paul over, as I half suspect she has, I must let her know
the consequences of her work, and see whether she persists in
abiding by her determination. It may be only some lovers' quarrel;
Paul is a mere boy in these matters, and hotheaded enough to take
au sérieux what may have been only the result of pique or woman's
whim; in that case, when she finds the effect that her quarrel has
had upon him, she will probably repent, and her penitence will aid in
bringing him round. On the other hand, if she still continues
obdurate, one may be able to point out to him the fact that he is
eminently well rid of so heartless a person. Not but what my little
experience in such matters," said George with a sigh, "teaches me
that lovers are uncommonly hard to convince of whatever they do
not wish to believe."

In pursuance of this determination George Wainwright, so soon as


he had installed the landlady in Paul's apartment as temporary
nurse, started off in search of Daisy. He had listened to so many of
poor Paul's confidences that he knew where the girl was to be
found, and made his way straight to George Street.
Madame Clarisse was still away, and Daisy continued her
occupancy of the little furnished rooms, into which George was
ushered on inquiring for Miss Stafford. The rooms were empty on
George's entrance, and he walked round them, examining the
various articles of furniture and decoration with very contemptuous
glances. Presently Daisy entered, and George stood transfixed in
admiration. She looked magnificently handsome; the announcement
of the name of her visitor had brought a bright flush into her cheek,
and anticipating a stormy interview, she had come prepared to do
battle with all the strength at her command, and accordingly
assumed a cold and haughty air which became her immensely.

The transient glimpses which George had had of her that day in
Kensington Gardens, though it had given him a general notion of her
style, had by no means prepared him for the sight of such rare
beauty. He was so taken aback that he allowed her to speak first.

"Mr. Wainwright, I believe?" said Daisy with a slight inclination of


her head.

"That's my name," said George, coming to himself.

"The servant told me that you asked for me, that you wished to
see me; I am Miss Stafford."

"The servant explained my wishes correctly," said George; "I have


come to see you, Miss Stafford, on a very important and, I grieve to
add, a very unpleasant matter."

Daisy looked at him steadily. "Will you be seated?" she said,


motioning him to a chair, at the same time taking one herself.

"I have come to you," said George, bending forward and speaking
in a low and earnest tone of voice, "on behalf of Mr. Paul Derinzy.
Not that I am sent by him; I have come of my own accord. You may
be aware, Miss Stafford, that I am Mr. Derinzy's intimate friend, and
possess his confidence in no common degree."
"I have heard Mr. Derinzy frequently mention your name, and
always with the greatest regard," said she.

"If we were merely going to speak the jargon of the world, Miss
Stafford, I might say that I could return the compliment," said
George. "However, what I wish you to know is, that in his confidence
with me Paul Derinzy had spoken openly and frankly of his affection
for you, and, indeed, made me acquainted with all the varieties of
his doubts, fears, and other phases of his attachment."

Daisy bowed again very coldly.

"You and Paul are both very young, Miss Stafford," continued
George, "and I have the misfortune of being much older than either
of you. This, however, has its advantage perhaps, in enabling me to
speak more frankly and impartially than I otherwise could. You must
not be annoyed at whatever I find it necessary to say, Miss Stafford;
for the situation is a very grave one, and more than you can at
present imagine depends upon the decision at which you may
arrive."

"Pray go on, Mr. Wainwright," said Daisy; "you will find me


thoroughly attentive to all you have to say."

"I must be querist as well as pleader, and introduce some cross-


examination into my speech, I am afraid," said George; "but you
may depend on my neither saying nor asking anything more than is
absolutely necessary. And in the first place let me tell you, what
indeed you already know, that this boy loves you with all the ardour
of a very affectionate disposition. I don't know whether you set
much store by that, Miss Stafford; I do know that young ladies of
the present day indulge in so many flirtations, and see so many
shams and counterfeits of the passion, that they are scarcely able to
recognise real love when they see it, and hardly ever able to
appreciate it. But it is a thing that, when once obtained, should not
be lightly let go; and indeed, Owen Meredith thinks quite right--you
read poetry, I know, Miss Stafford; I recollect Paul having told me
so--when he says:
Beauty is easy enough to win,
But one isn't loved every day."

"I presume it was not to quote from Owen Meredith that you wished
to see me, Mr. Wainwright," said Daisy, looking up at him quietly.

George stared at her for a moment, but was not one bit
disconcerted.

"No," he said, "it was not; but I am in the habit of using quotation
when I think it illustrates my meaning, and those lines struck me as
being rather apt. However, we come back to the fact that Paul
Derinzy was, and I believe is, very much in love with you. From what
he gave me to understand, I believe I am right in saying that that
passion was at one time returned. I believe--I wish to touch as
lightly as possible on unpleasant matters--I believe that recently
there has been some interruption of the pleasant relation which
existed between you--an interruption emanating from you--and that
Paul has consequently been very much out of spirits. Am I right?"

"You are very frank and candid with me, Mr. Wainwright," said
Daisy, "and I will endeavour to answer you in the same manner. I
perfectly admit that the position which Mr. Derinzy and I occupy
towards each other is changed, and changed by my desire."

"You will not think me impertinent or exacting--you certainly will


not when you know all I have to tell you--if I ask what was the
reason for that change?"

Daisy's face flushed for an instant, then she said:

"A woman's reason--because I wished it."

George nodded as though he perfectly comprehended her; but he


gazed at her all the time.
"May I ask, has this altered state of feeling come to a head? has
there been any open and decisive rupture between you lately?"

"If you are not sufficiently in Mr. Derinzy's confidence to have that
information from him, I scarcely think you ought to ask it of me,"
said Daisy.

"Unfortunately, Mr. Derinzy, is not at present in a position to


answer me."

"Not in a position to---- What do you mean?" asked Daisy, leaning


forward.

"I will tell you before I go," said George. "In the meantime,
perhaps you will kindly reply to me."

"There has been no actual quarrel between us," said the girl--"that
is to say, no personal quarrel; but----" and she spoke with so much
hesitation, that George instantly said:

"But you have taken some decisive action."

Daisy was silent.

"You have told him that all must be over between you; that you
would not see him again, or something to that effect."

"I--I wrote him a letter conveying that decision," said Daisy slowly.

"And you addressed to him----"

"As usual, at his club."

"By Jove, that's it!" said George, springing up. "Now, Miss
Stafford, let me tell you the effect of that letter. Paul Derinzy was
picked up from the floor of the club-library in a fit!"

"Good God!" cried Daisy.


"One moment," continued George, holding up his hands. "He was
carried home insensible, and now lies between life and death. He is
delirious and knows no one, but lies tossing to and fro on his bed,
ever muttering your name, ever recalling scenes which have been
passed in your company. When I saw him in this state, when I heard
those groans, and recognised them as the utterances of the mental
agony which he was suffering, I thought it my duty to come to you.
Understand, I make no ad misericordiam appeal. There is no
question of my throwing myself on your feelings, and imploring you
to have pity on this boy. I imagine that, even with all his passion for
and devotion to you, he is far too proud for that, and would disclaim
my act so soon as he knew of it. But, loving him as I do, I come to
you and say, 'This is your work.' What steps you should take, if any,
it is for you to determine. I say nothing, advise nothing, hint
nothing, save this: if what you wrote in that letter to Paul was final
and decisive, the result of due reflection, the conviction that you
could not be happy with him, then stand by it and hold to it; for if
you were to give way merely for compassion's sake, his state would
be even worse than it is now. But if you spoke truth to me at the
beginning of this interview, if your dismissal of Paul was, as you
described it, a woman's whim, conceived without adequate reason,
and carried out in mere wantonness, I say to you, that if this boy
dies--and his state even now is most critical--his death will lie at
your door."

Daisy had been listening with bent head and averted eyes. All
evidence of her having heard what George had said lay in a nervous
fluttering motion of her hand, involuntary and beyond her control.
When George ceased, she looked up, and said in a hard, dry voice:

"What will you have me do?"

"I told you at first that I would give you no advice, that I would
make no suggestion as to the line of conduct you should pursue.
That must be left entirely to the promptings of your heart, and--
excuse me, Miss Stafford, I am sadly old-fashioned, and still believe
in the existence of such things--your conscience."

"Is he--is he so very ill?" asked Daisy in a trembling voice.

"He is very dangerously ill," said George; "he could not be worse.
But understand, I don't urge this to influence your decision, nor
must you let it weigh with you. Your action in this matter must be
the result of calm deliberation and self-examination. To act on an
impulse which you will repent of when the excitement is over, is
worse than to leave matters where they are."

"He--he is delirious, you say?" asked Daisy; "he does not


recognise anyone?"

"No, he is quite delirious," said George. "He will have to be


carefully attended, and I am now going to see after a nurse. So," he
added, rising from his chair, "having discharged my duty, I will now
proceed on my way. I am sorry, Miss Stafford, that on my first visit
to you I should have been the bearer of what, to me at least, is such
sad news."

Then he bowed in his old-fashioned way, and took his departure.

After George left her, Daisy dropped back into the chair which she
had occupied during his visit, and sat gazing vacantly into the fire.

Calm deliberation and self-examination! Those were what that


strange earnest-looking man, Mr. Wainwright, had said he left her to.
In the state of anxiety and excitement in which she found herself,
the one was impossible, and she shrank from the other. Self-
examination--what would that show her? A girl, first winning, then
trifling with the affections of a warmhearted young fellow, who
worshipped her and was ready to sacrifice everything in life for her.
And the same girl, hitherto so proud in her virtue and her self-
command, paltering and chaffering for her honour with a man, the
best thing which could be said about whom was, that he had spoken
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like