(Ebook) Java Network Programming by Harold, Elliotte ISBN 9781449357672, 1449357679 All Chapters Instant Download
(Ebook) Java Network Programming by Harold, Elliotte ISBN 9781449357672, 1449357679 All Chapters Instant Download
com
https://ebooknice.com/product/java-network-
programming-55585978
DOWLOAD EBOOK
https://ebooknice.com/product/java-network-programming-4427642
ebooknice.com
https://ebooknice.com/product/java-network-programming-third-
edition-2332242
ebooknice.com
ebooknice.com
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
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
ebooknice.com
https://ebooknice.com/product/xml-bible-923002
ebooknice.com
https://ebooknice.com/product/xml-bible-gold-edition-1927878
ebooknice.com
ebooknice.com
FOURTH EDITION
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
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
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 | ix
Configuring SSLServerSockets 343
Choosing the Cipher Suites 343
Session Management 344
Client Mode 344
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
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:
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.
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.
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.
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:
• Command lines and options that should be typed verbatim on the screen
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!).
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.
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:
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
• 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
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.
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.
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 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.
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.
"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."
"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."
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.
"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.
"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."
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.
"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."
"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."
"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."
"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."
"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."
"That seems a first-rate arrangement, sir," said he; "I hope you
may find you can carry it out in all particulars."
"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."
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."
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!"
"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."
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.
"The servant told me that you asked for me, that you wished to
see me; I am Miss Stafford."
"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."
"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."
"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."
"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.
"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:
"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.
"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!"
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:
"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."
"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."
After George left her, Daisy dropped back into the chair which she
had occupied during his visit, and sat gazing vacantly into the fire.
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.
ebooknice.com