0% found this document useful (0 votes)
8 views

Java Network Programming Fourth Edition Harold Elliotte instant download

The document is a promotional listing for the book 'Java Network Programming, Fourth Edition' by Elliotte Rusty Harold, along with links to download various related programming books. It includes a detailed table of contents outlining the chapters and topics covered in the book, such as basic network concepts, streams, threads, and secure sockets. The book is published by O'Reilly Media and is intended for educational and professional use.

Uploaded by

pjuelbj7772
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Java Network Programming Fourth Edition Harold Elliotte instant download

The document is a promotional listing for the book 'Java Network Programming, Fourth Edition' by Elliotte Rusty Harold, along with links to download various related programming books. It includes a detailed table of contents outlining the chapters and topics covered in the book, such as basic network concepts, streams, threads, and secure sockets. The book is published by O'Reilly Media and is intended for educational and professional use.

Uploaded by

pjuelbj7772
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Java Network Programming Fourth Edition Harold

Elliotte download

https://textbookfull.com/product/java-network-programming-fourth-
edition-harold-elliotte/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Learning Network Programming with Java 1st Edition


Reese Richard M

https://textbookfull.com/product/learning-network-programming-
with-java-1st-edition-reese-richard-m/

Neural Network Programming with Java Create and unleash


the power of neural networks by implementing
professional Java code 1st Edition Souza

https://textbookfull.com/product/neural-network-programming-with-
java-create-and-unleash-the-power-of-neural-networks-by-
implementing-professional-java-code-1st-edition-souza/

Java Programming Joyce Farrell

https://textbookfull.com/product/java-programming-joyce-farrell/

Java Programming Joyce Farrell

https://textbookfull.com/product/java-programming-joyce-
farrell-2/
Java pocket guide Fourth Edition Robert Liguori

https://textbookfull.com/product/java-pocket-guide-fourth-
edition-robert-liguori/

Programming in Java Sachin Malhotra

https://textbookfull.com/product/programming-in-java-sachin-
malhotra/

Python Network Programming Cookbook Kathiravelu

https://textbookfull.com/product/python-network-programming-
cookbook-kathiravelu/

CompTIA Network Review Guide Fourth Edition. Edition


Craig Zacker

https://textbookfull.com/product/comptia-network-review-guide-
fourth-edition-edition-craig-zacker/

Learning Java Beginning programming with java for


dummies First Edition John Bach

https://textbookfull.com/product/learning-java-beginning-
programming-with-java-for-dummies-first-edition-john-bach/
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 corporate@oreilly.com.
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


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
Another Random Scribd Document
with Unrelated Content
CHAPTER XXVII.
Personal and Practical.

HAVE alluded to the intense blaze of the sun upon the day
of our tryst with the newly-arrived travelers. Until then we
had not suffered from heat in Switzerland. Our pension was
a stone building, with spacious, high-ceiled rooms, in which
the breeze from lake and icy mountains was ever astir, and we were
rarely abroad excepting at morning and evening.
On our way home the next afternoon, after a delightful sail to
Fluelen and back, and a visit to Altorf, we met Boy and nurse at the
gate of the public park where he and I went daily for the “milk-cure.”
Three or four cows and twice as many goats were driven into the
enclosure at five o’clock and tethered at the door of a rustic pavilion.
There they were milked, and invalids and children drank the liquid
warm from great tumblers like beer-glasses. Goats’ milk had been
prescribed for me, and I could endure the taste when it was fresh.
When cold, the flavor was peculiar and unpleasant. Boy usually
relished his deep draught of cows’ milk, but to-day he would not
touch it. He had a grievance, too, that had tried temper and pride.
“Things bother me so, mamma! The people here are so foolish! A
woman had some fruit to sell down there by the Schweizerhof and
said a long nonsense to me. I said—‘Non capisco Tedeseo!’ and
everybody laughed. It’s good Italian, and means—‘I don’t
understand a word of your horrid old Dutch!’”
He began to sob. Papa picked him up and carried him to our
carriage. When we were in our rooms, the Invaluable had her story
to tell. Boy had taken a long walk with his sister in the forenoon and
had come home complaining of headache and violent nausea.
Seeming better toward evening, he had insisted upon going for his
milk, and she had hoped the cooler air would refresh him.
“I want to go back where people have sense and can understand
me!” moaned the little fellow. “I’m not a bit sick! I’m discouraged!”
The fever ran high all night. The following day we summoned Dr.
Steiger, the best physician in Lucerne. There are few better
anywhere. For the next fortnight—the saddest of our exile—his visits
were the brightest gleams in the chamber shadowed by such wild
fears as we hardly dared avow to one another. Cheerful, intelligent,
kindly, the doctor would have been welcome had his treatment of
our stricken child been less manifestly skillful.
“He is a sick boy. But you are brave?” looking around at us from
his seat at the pillow of the delirious patient. “I will tell you the
truth. He has had a coup de soleil. He is likely to have a long fever.
It is not typhoid yet, but it may be, by and by. Strangers unused to
the sun in Switzerland are often seriously affected by it. When he
gets well, you will be careful of him for one, two, three years. Now—
we will do our best for him. I have four boys of my own. And—”a
quick glance at me—“I know what is the mother’s heart!”
I would not review, even in thought, the three weeks succeeding
this decision, were it not that I cannot bring myself to withhold the
tribute of grateful hearts—then so heavy! to the abundant goodness
of the stranger-physician whose name we had never heard until our
boy’s illness, and to the sympathy and active kindness that were our
portion from every boarder in a house filled with English and
Americans. Jellies, ices, fruit, flowers, toys, were handed in at Boy’s
door, with tender inquiries, from hour to hour, as to his condition.
Music-loving girls who had scarcely left the piano silent for fifteen
minutes during the day and evening, now closed it lest the sufferer
should be disturbed by the sound, his chamber being directly over
the salon. Every foot trod softly upon the polished floor of the upper
hall and the stairs, and offers of personal service were as earnest
and frequent as if we had dwelt among our own people. I write it
down with a swelling heart that presses the tears to my eyes. For
Heaven knows how sore was our need of friendly offices and Good
Samaritans at that juncture! The house was handsome, well-
furnished and kept beautifully clean. Well people fared comfortably
enough. But, for sickness we found, as we had everywhere else—
notably at Cadenabbia—no provision whatever, and with regard to
dietetic cookery, depths of ignorance that confounded us.
I could not for money—much less for love or pity’s sake—get a
cup of gruel or beef-tea made in the kitchen. When Boy was
convalescent and his life depended upon the judicious administration
of nourishment, I tried to have some oatmeal porridge cooked,
according to directions, below stairs, paying well for the privilege.
There were two pounds of oatmeal in the package. I ordered half-a-
cupful to be boiled a long time in a given quantity of water, stirred
up often from the bottom and slightly salted. The cook—a professed
cordon bleu—cooked it all at once and sent it up in a prodigious
tureen,—a gallon of soft, grayish paste, seasoned with pepper, salt,
lemon-peel and chopped garlic!
I did give the landlady credit for an inexplicable fit of motherly
kindness when, at length, fish and birds, nicely broiled, came up,
every day or two, to brighten the pale little face laid against the
cushions of his lounge; thanked her for them heartily and with
emotion.
“It is not’ing!” she said, beaming (as when was she not?) “I only
wis’ to know dat de beautiful child ees better. I t’ought he could
taste de feesh.”
I was grateful and unsuspicious for a week, recanting,
repentantly, the hard things I had said of continental human nature,
and admitting Madame to the honorable list of exceptions, headed—
far above hers—by Dr. Steiger’s name. Then, chancing to come
down-stairs one day, shod with the “shoes of silence” I wore in the
sick-room, I trod upon the heels of a handsome young Englishman,
almost a stranger to me, who was spending the honeymoon with his
bride in Switzerland. He had been three weeks in this house, and we
had not exchanged ten sentences with him or his wife. He stood
now in the hall, his back toward me, in close conference with
Madame, our hostess. He was in sporting-costume, fishing-rod on
shoulder. Madame held a fine fish, just caught, and was receiving his
instructions delivered in excellent French:
“You will see that it is broiled—with care—you know, and sent, as
you have done the others, to the little sick boy in No. 10. And this is
for the cook!”
There was the chink of coin. The cook! whom I had feed
generously and regularly for preparing the game and fish so
acceptable to my child!
I stepped forward. “It is you, then, Mr. N——, whom I should
thank!” with a two-edged glance that meant confusion to Madame,
acknowledgment and apology to the real benefactor.
The young Briton blushed as if detected in a crime. Madame
smiled, without blushing, and bustled off to the kitchen.
Happily, Americans are not without “contrivances” even on the
Continent. A summary of ours while the fever-patient needed
delicate food such as American nurses and mothers love to prepare,
may be useful to other wayfarers on the “road to Jericho.” We
carried our spirit-lamp and kettle with us everywhere. Besides these,
I bought a small tin saucepan with a cover and a tin plate; made a
gridiron of a piece of stout wire, and set up a hospital kitchen in one
of our rooms at an open window that took smoke and odor out of
the way. Here, for a month, we made beef-tea, broiled birds and
steak and chops—the meat bought by ourselves in the town; cooked
omelettes, gruel, arrowroot jelly, custards, and boiled the water for
our “afternoon tea.” Cream-toast was another culinary success, but
the bread was toasted down-stairs by the Invaluable when she could
get—as she phrased it—“a chance at the kitchen-fire.” Cream and
butter were heated in the covered tin-cup over our lamp.
For fifteen days, the fever ran without intermission, sometimes so
fiercely that the brain raged into frenzied wanderings; for three
weeks, our Swiss doctor came morning, afternoon or evening—
sometimes all three; for a month, our boy was a prisoner to his own
room, and we attended upon his convalescence before daring to
strike camp and move northward into Germany. And all in
consequence of that long walk, without shade of trees or umbrella,
under the treacherous Swiss sun! We had had our lesson. I pass it
on to those who may be willing to profit thereby.
But for this unfortunate break in our plans we would have had a
happy month in Lucerne. We could not stir out of doors without
meeting friends from over the sea, and, every day, cards, inscribed
with familiar names, were brought in to us. All the American
traveling-world goes to the Swiss lakes and crosses the Passes in the
short summer. Lucerne is picturesque in itself and environs. The lake
ranks next to Como in beauty; the drives and walks in and about it
are attractive in scenery and associations. Of the healthfulness of
those portions of the town lying along the quay we had grave
doubts. The cellars are flooded after every heavy rain, and copious
rains are a feature of the climate. Our morning walk for our letters
lay past one of the largest hotels, patronized extensively by English
and Americans. A rainy night or day was sure to be followed by an
opening of the rear basement windows, and a pumping into the
gutter of hogsheads of muddy water. The rapid evaporation of the
surplus moisture under the mid-day heats must have filled the
atmosphere with noxious exhalations.
The evening-scene on the quay was brilliant. Hundreds of strollers
thronged the broad walks beneath the trees; the great fountain
threw a column of spray fifty feet into the air. A fine band played
until ten o’clock before the Hôtel National; pleasure-boats shot to
and fro upon the water; the lamps of the long bridge sparkled—a
double row—in the glassy depths. Upon certain evenings, the Lion
held levees, being illuminated by colored lights thrown upon the
massive limbs that seemed to quiver under their play, and upon the
roll of honor of those who died for their queen and for their oath’s
sake.
Lucerne is very German in tongue and character—a marked and
unpleasant change to those who enter Switzerland from the Italian
side. Ears used to the flowing numbers of the most musical language
spoken by man, are positively pained by the harsh jargon that
responds to his effort to make himself intelligible. The English and
French of the shopkeepers and waiters, being filtered through the
same foul medium, is equally detestable. Our friend, Dr. Steiger,
spoke all three languages well and with a scholarly intelligence that
made his English a model of conciseness and perspicuity. Our
experiences and difficulties with other of the native residents would
make a long chapter of cross-purposes.
Three times a week the fruit-market is held in the arcades of the
old town. One reaches them by crooked streets and flights of stone
steps, beginning in obscure corners and zigzagging down to the
green Reuss, swirling under its bridges and foaming past the light-
house tower to its confluence with the Lake. The summer fruits
were, to our ideas, an incongruous array. Strawberries—the small,
dark-red “Alpine,” conical in shape, spicily sweet in flavor;
raspberries, white, scarlet and yellow; green and purple figs;
nectarines; plums in great variety and abundance; apples, peaches
and pears; English medlars and gooseberries; Italian nespoli and
early grapes were a tempting variety. We had begun to eat
strawberries in April in Rome. We had them on our dessert-table in
Geneva in November.
The second time I went to the fruit-market, I took Prima as
interpreter. The peasant-hucksters were obtuse to the pantomime I
had practised successfully with the Italians. The shine of coin in the
left palm while the right hand designated fruit and weight—
everything being sold from the scales—elicited only a stolid stare
and gruff “Nein,” the intonation of which was the acme of dull
indifference. Thick of tongue and slow of wit, they cared as little for
what we said as for what we were. Intelligence and curiosity may
not always go hand-in-hand, but where both are absent, what the
Yankees call “a trade,” is a disheartening enterprise. Having at my
side a young lady who “knew” German, I advanced boldly into the
aisle between the stalls of the sellers, and said—“Ask this woman the
price of those gooseberries.” Big, red and hairy as Esau, they were a
lure to American eyes and palates. Prima put the question with a
glibness truly pleasing to the maternal heart, however the gutturals
might grate upon the ear. The vender’s countenance did not light up,
but she answered readily, if monotonously. Prima stared at her,
disconcerted.
“What does she say? That is not German!”
Italian and French were tried. The woman gazed heavily at the
Wasserthurm, the quaint tower rising from the middle of the river
near the covered bridge of the Capelbrücke, and remained as
unmoved as that antique land-mark.
“This has ceased to be amusing!” struck in Caput, imperatively,
and turning about, made proclamation in the market-place—“Is
there nobody here who can speak English?”
A little man peeped from a door behind the stall. “I can!”
The two monosyllables were the “Open Sesame” to the fruity
wealth that had been Tantalus apples and a Barmecide banquet and
whatever else typifies unfulfilled desire to us, up to the moment of
his appearing.
“How odd that the woman should understand me when I did not
comprehend a word she said!” meditated our discomfited interpreter,
aloud.
The enigma was solved at lunch, where the story was told and
the ridiculous element made the most of. A pretty little Russian lady
was my vis-à-vis. The Russians we met abroad were, almost without
exception, accomplished linguists. They are compelled they say,
jestingly, to learn the tongues of other peoples, since few have the
courage and patience to master theirs. My neighbor’s English caused
us to fall in love with our own language. Her speech with her
children was in French, and she conversed with German gentlemen
at the table with equal facility.
“Your daughter is quite correct in her description of the Lucerne
dialect,” she said, rounding each syllable with slow grace that was
not punctiliousness. “It is a vile mongrel of which the inhabitants
may well be ashamed. I have much difficulty in comprehending their
simplest phrases, and I lived in Germany five years. The Germans
would disown the patois. It is a provincial composite. The better
classes understand, but will not speak it.”
I take occasion to say here, having enumerated the summer-
delicacies offered for sale in the Lucerne market, that those of our
countrypeople who visit Europe with the hope of feasting upon such
products of orchard and garden as they leave behind them, are
doomed to sore disappointment. Years ago, I heard Dr. E. D. G.
Prime of the “New York Observer,” in his delightful lecture, “All
Around the World,” assert that “the finest fruit-market upon the
globe is New York City.” We smiled incredulously, thinking of East
Indian pine-apples and mangoes, Seville oranges and Smyrna
grapes. We came home from our briefer pilgrimage, wiser, and
thankfully content. We murmured, not marveled at the pitiful display
of open-air fruit in England, remembering the Frenchman’s
declaration that baked apples were the only ripe fruit he had tasted
in that cloudy isle. Plums and apricots there are of fair quality, the
trees being trained upon sunny walls, but the prices of these are
moderate only by contrast with those demanded for other things.
Peaches are sixpence—(twelve-and-a-half cents) each. Grapes are
reared almost entirely in hot-houses, and sell in Covent Garden
market at two and three dollars a pound. Pears, comparable to the
Bartlett, Seckel or Flemish Beauty are nowhere to be had, and, in
the same celebrated market of fruit and flowers, “American apples”
were pressed upon us as the finest, and, therefore, costliest of their
kind. Gooseberries are plentiful and quite cheap, as are cherries and
currants. Pine-apples in England—“pines”—bring a guinea or a half-
guinea apiece, being also, hot-house products.
“Do the poor eat no fruit?” I asked our Leamington fruiterer, an
intelligent man whose wares were choice and varied—for that
latitude.
“They are permitted to pick blackberries and sloes in the edges.
Of course, pines and peaches are forbidden luxuries to people in
their station.”
He might have added—“And plums at two cents, apricots at four,
pears at five cents apiece, and strawberries”—charged against us by
our landlady at half-a-dollar per quart in the height of the season.
Tomatoes ranged from six to twelve cents apiece! asparagus was
scarce and frightfully dear; green peas, as a spring luxury, were
likewise intended for rich men’s tables. For Indian corn, sweet
potatoes, egg-plants, Lima and string-beans, summer squash and
salsify we inquired in vain. Nor had any English people to whom we
named these ever seen them in their country. Many had never so
much as heard that such things were, and asked superciliously
—“And are they really tolerable—eatable, you know?”
Our English boarders in Lucerne smiled, indulgent of our national
peculiarities,—but very broadly—at seeing us one day at the
pension-table, eat raw tomatoes as salad, with oil, vinegar, pepper
and salt. They were set in the centre of the board as a part of the
dessert, but our instructions to the waiters broke up the order of
their serving. Madame and daughters confessed, afterward, that
they were not certain where they belonged, but had heard that
Americans liked tomatoes, and so procured them.
Matters mended, in these respects, as we moved southward.
When the weather is too hot, and the climate too unwholesome for
foreigners to tarry in Southern France and Italy, the natives revel in
berries, peaches and melons. We ate delicious grapes in Florence as
late as the first of December, and a few in Rome. By New Year’s Day,
not a bunch of fresh ones was exhibited in shops, at this time, filled
with sour oranges, sweet, aromatic mandarini, mediocre apples and
drying nespoli and medlars. The nespoli, let me remark, is a hybrid
between the date and plum, with an added cross of the persimmon.
Indeed, it resembles this last in color and shape, also, in the acerbity
that mingles with the acid of the unripe fruit. When fully matured
they are very good, when partially dried, not unlike dates in
appearance and flavor. Medlars are popular in England, and in
request in Paris. To us, they were from first to last, disagreeable. To
be candid, the taste and texture of the pulp were precisely those of
rotten apples. We thought them decayed, until told that they were
only fully ripe. In these circumstances how tantalizing were
reminiscences of Newtown and Albemarle pippins, of Northern Spy
and Seek-no-further! We could have sat us down on the pavement
of the Piazza di Spagna, and, hidden by mountains of intolerably tart
oranges, plained as did the mixed multitude at Taberah, that our
souls were dried away in remembering the winter luxuries of which
we did eat freely in our own land; the Catawba, Isabella and Diana
grapes, close packed in purple layers in neat boxes for family use,
late pears and all-the-year-round sweet oranges; plump, paly-green
Malaga and amethyst Lisbon grapes, retailed at thirty and twenty-
five cents per pound. Were we not now upon the same side of the
ocean with Lisbon and Malaga? It was nearly impossible to credit the
scarcity of these sun bright lands in what we had so long received
and enjoyed as everyday mercies to people of very moderate means.
As to bananas, we did not see a dozen in two years. I did not
taste one in all that time. Desiccated tomatoes and mushrooms are
sold in Italian cities by the string. Canned vegetables are an
American “notion.” Brown, in the Via della Croce in Rome, had fresh
oysters—American—for eighty cents a can. As the daintiest canned
peas and the useful champignons are imported by United States
grocers direct from France, it was odd that we could not have them,
for the asking, in Switzerland and Italy. Esculents for salad grow
there out of doors all winter, including several varieties not cultivated
with us. Potatoes, spinach, rice, celery,—cooked and raw—onions,
cabbage, cauliflower, macaroni, a root known as “dog-fennel,” and,—
leading them all in the frequency of its appearing, but not, to most
people’s taste, in excellence,—artichokes—are the vegetable bill-of-
fare. If there are eight courses at dinner, the probability is that but
two of them will be vegetables. An eight-course dinner on the
Continent may be a very plain affair, important as it sounds, and the
diner-out be hardly able to satisfy a healthy appetite ‘though he
partake of each dish. Soup is the first course;—sometimes,
nourishing and palatable,—as often, thin and poor. Fish succeeds. If
it be salmon, whitebait, whitings, soles or fresh sardines, it is usually
good. But, beyond Paris, we were rarely served on the Continent
with any of these, except the last-named, that could be truthfully
called, “fresh.” The sardines of Naples and Venice, just from the
water, are simply delicious.
Meat comes next—a substantial dish, and an entrée of some sort.
These are separated by a course consisting of a single vegetable,
potatoes or stewed celery or macaroni au gratin, or, perhaps,
cauliflower with sauce tartare. Another vegetable precedes the first
meat-course. Salad follows the second. Then, we have pastry or
some other sweet, and dessert, meaning fruit, nuts and bon-bons.
Finally, coffee. The dinner is à la Russe, no dishes being set upon
the table, excepting the dessert. The carving is done in another
room and the guests are not tempted to gluttony by the amount
served to each.
“If they would only give me a potato with my boiled fish!”
lamented an American to me, once. “Or serve the green peas with
the lamb! And mutton-chops and tomato-sauce are as naturally
conjoined in the educated mind as the English q and u!”
On the Continent the exception to the rule he objurgated is the
serving of chicken and salad—lettuce, endive or chervil,—together
upon a hot plate. The vinegar and oil cool the chicken. The heated
plate wilts and toughens the salad. Common sense might have
foretold the result. But chicken-and-salad continue to hold their rank
in the culinary succession, and are eaten without protest by those
who are loudest in ridicule and condemnation of transatlantic
solecisms.
CHAPTER XXVIII.
Home-life in Geneva—Ferney.

UR German experiences, sadly curtailed as to time by Boy’s


sickness, scarcely deserve the title of “loiterings.” We
passed two days in Strasburg; as many in Baden-Baden, a
day and night at Schaffhausen; a week in Heidelberg; a few hours at
Basle, etc., etc., too much in the style of the conventional tourist to
accord with our tastes or habits. At Heidelberg our forces were
swelled by the addition of another family party, nearly allied to ours
in blood and affection. There, we entered upon a three weeks’ tour,
a pleasant progress that had no mishap or interruption until we re-
crossed the Alps into Switzerland, this time by the Brünig Pass,
traveling as we had done over the St. Gothard, en famille, but in two
diligences, instead of one, taking in Interlaken, The Staubbach,
Lauterbrunnen, Grindelwald, the Wengernalp, Freiburg, Bern and a
host of other notable places and scenes, and brought up, in tolerable
order, if somewhat travel-worn, at ten o’clock one September night,
in Geneva.
We were to disband here; one family returning to Germany; Miss
M—— going on to Paris; ourselves intending to winter again in Italy.
I had enjoyed our month of swift and varied travel the more for the
continual consciousness of the increase of health and strength that
enabled me to perform it. But I had taken cold somewhere. The old
cough and pain possessed me, and for these, said men medical and
non-medical, Geneva was the worst place one could select in
autumn or winter. The bise, a strong, cold, west wind, blows there
five days out of seven; for weeks the sun is not visible for the fog;
rain-storms are frequent and severe, and the atmosphere is always
chilled by the belt of snow-mountains. This was the meteorological
record of the bright little city, supplied by those who should have
known of that whereof they spoke.
For three days after our arrival, it sustained this reputation. The
bise blew hard and incessantly, filling the air with dust-clouds and
beating the lake into an angry sea that flung its waves clear across
the Pont du Mont Blanc, the wide, handsome bridge, uniting the two
halves of the city. I sat by the fire and coughed, furtively. Caput
looked gravely resolute and wrote letters to Florence and Rome.
Then, Euroclydon—or Bise,—subsided into calm and sunshine, and
we sallied forth, as do bees on early spring-days, to inspect the town
—“the richest and most popular in Switzerland.” (Vide Baedeker.)
The air was still cool, as was natural in the last week of
September, but as exhilarating as iced champagne. Respiration
became suddenly easy, and motion, impulse, not duty. We walked up
the Quai Eaux Vives to the first breakwater that checks the too-
heavy roll of the waves in stormy weather; watched the wondrous,
witching sheen of ultramarine and emerald and pearly bands upon
the blue lake; down the broad quay by the English Gardens, through
streets of maddening shop-windows, a brilliant display of all that
most surely coaxes money from women’s pockets;—jewelry,
mosaics, laces, carvings in wood and in ivory, photographs, music-
boxes,—a distracting medley, showed to best advantage by the
crystalline atmosphere. We crossed to Rousseau’s Island in the
middle of the lake by a short chain-bridge attaching it to the Pont
des Bergues, and fed the swans who live, eat and sleep upon the
water; marked the point where the Rhone shoots in arrowy flight
from the crescent-shaped lake to its marriage with the slower Arve
below the city. Thence, we wound by way of the Corraterie, a busy
street, formerly a fosse, to the Botanical Gardens; skirted the
Bastions from which the Savoyards were thrown headlong at the
midnight surprise of the “Escalade,”—and were in the “Old Town.”
This is an enchanting tangle of narrow, excursive streets, going up
and down by irregular flights of stone steps; of antique houses with
bulging upper stories and hanging balconies and archways, and
courts with fountains where women come to draw water and stay to
gossip and look picturesque, in dark, full skirts, red boddices and
snowy caps. We passed between the National Cathedral of St. Pierre
and the plain church where Père Hyacinthe preached every Sabbath
to crowds who admired his eloquence and had no sympathy with his
chimerical Reformed Catholicism; along more steep streets into a
newer quarter, built up with handsome mansions,—across an open
space, climbed a long staircase and were upon the hill on which
stands the new Russian Church.
It is a diminutive fabric, made the most of by a gilded dome and
four gilt minarets, and by virtue of its situation, contrives to look
twice as big as it is, and almost half as large as the old Cathedral
which dates from 1024.
Geneva was below us, and diverging from it in every direction,
like veins from a heart, were series of villas, châteaux and humbler
homes, separated and environed by groves, pleasure-grounds and
hedge-rows. The laughing lake, which seldom wears the same
expression for an hour at a time, was dotted with boats that had not
ventured out of harbor while the wind-storm prevailed. Most of these
carried the pretty lateen sail. The illusion of these “goose-winged”
barques is perfect and beautiful, especially when a gentle swell of
the waves imparts to them the flutter of birds just dipping into, or
rising from the surface;—birds statelier than the swans, more airy
than the grebe circling above and settling down upon the Pierres du
Niton. These are two flat boulders near the shore whereon tradition
says Julius Cæsar once sacrificed to Neptune,—probably to
propitiate the genius of the bise. Across the water and the strip of
level country, a few miles in breadth, were the Juras, older than the
Alps, but inferior in grandeur, their crests already powdered with
snow. On our side of the lake behind town and ambitious little
church,—outlying campagnes (country-seats) and dozens of villages,
arose the dark, horizontal front of the Saléve. It is the barrier that
excludes from Geneva the view of the chain of Alps visible from its
summit. Mont Blanc overtops it, and, to the left of its gleaming
dome, the Aiguilles du Midi pierce the sky. Others of the “Mont Blanc
Group” succeed, carrying on the royal line as far as the unaided eye
can reach. Between these and the city rises the Mole, a rugged
pyramid projecting boldly from the plain.
Chamouny, the Mer de Glace, Martigny, Lausanne, Vevay, Chillon,
Coppet, Ferney! To all these Geneva was the key. And in itself it was
so fair!
We talked less confidently of Italian journeyings, as we
descended the hill; more doubtfully with each day of fine weather
and rapidly-returning strength. Still, we had no definite purpose of
wintering in Geneva, contrary to the advice of physicians and
friends. It was less by our own free will than in consequence of a
chain of coincident events, which would be tedious in the telling,
that December saw us, somewhat to our astonishment, settled in
the “Pension Magnenat,” studying and working as systematically as if
Italy were three thousand watery miles away.
That a benignant Providence detained us six months in this place
we recognize cheerfully and thankfully. I question if Life has in
reserve for us another half-year as care-free and as evenly happy.
There are those who rate Geneva as “insufferably slow;” the
“stupidest town on the Continent,” “devoid of society except a mélée
of Arabs, or the stiffest of exclusive cliques.” Our American “clique”
may have been exceptionally congenial that year, but it supplied all
we craved, or had leisure to enjoy of social intercourse. Foreigners
who remain there after the middle of December, do so with an
object. The facilities for instruction in languages, music and painting
are excellent. Lectures, scientific and literary, are given throughout
the season by University professors and other savans. The prices of
board and lessons are moderate, and—an important consideration
with us and other families of like views and habits—Sabbath-school
and church were easy of access and well-conducted.
There were no “crush” parties, and had they been held nightly,
our young people were too busy with better things to attend them.
But what with music and painting-classes; German and French
“evenings;” reading-clubs in the English classics; the “five o’clock
tea” served every afternoon in our salon for all who would come,
and of which we never partook alone; what with Thanksgiving
Dinner and Christmas merry-making, when our rooms were bowers
of holly and such luxuriant mistletoe as we have never seen
elsewhere; with New Year Reception and birth-day “surprise;” daily
walks in company, and, occasionally a good concert, our happy-
family-hood grew and flourished until each accepted his share in it
as the shelter of his own vine and fig-tree. We were a lively coterie,
even without the divertissements of the parties of pleasure we got
up among ourselves to Coppet, Ferney, Chillon and the Saléve. Shall
we ever again have such pic-nics as those we made to the top of the
Grand Saléve—our observatory-mountain, driving out to the base in
strong, open wagons, then ascending on foot or on donkeys?
There are those who will read this page with smiles chastened by
tender thoughts of vanished joys, as one by one, the salient features
of those holiday excursions recur to mind. Donkeys that would not
go, and others that would not stop. The insensate oaf of a driver
who walked far ahead of the straggling procession and paid no
attention to the calls of bewildered women. The volunteer squad of
the stronger sex who strode between the riders and the precipice,
and beat back the beasts when they sheered dangerously close to
the edge. The gathering of the whole company for rest and survey
of the valley, at the stone cross half-way up. The explorations of
straggling couples in quest of “short cuts” to the crown of the upper
hill, and their return to the main road by help of the bits of paper
they had attached to twigs on their way into the labyrinth of
brushwood and stones. Who of us can forget the luncheons eaten
under the three forlorn trees that feigned to shade the long, low hut
on the summit? When, no matter how liberal our provision,
something always gave out before the onward rush of appetites
quickened by the keen air? How we devoured black bread bought in
the Châlet where we had our coffee boiled, and thought it sweeter
than Vienna rolls! Do you remember—friends belovéd—now so sadly
and widely sundered—the basket of dried thistles proffered gravely,
on one occasion, and to whom, when the cry for “bread” was
unseemly in vociferation and repetition? And that, when our hunger
was appeased, we, on a certain spring day, roamed over the breast
of the mighty mount, gathering gentians, yellow violets, orchis and
scraggy sprays of hawthorn, sweet with flowers, until tired and
happy, we all sat down on the moss-cushions of the highest rocks,
and looked at Mont Blanc—so near and yet so far,—stern, pure,
impassive,—and hearkened to the cuckoo’s song?
I know, moreover, because I recollect it all so well, that you have
not forgotten the as dear delights of talking over scene and
adventure and mishap—comic, and that only in the rehearsal,—on
the next rainy afternoon. When we circled about the wood-fire, tea-
cups in hand, raking open the embers and laying on more fuel that
we might see each others’ faces, yet not be obliged to light the
lamps while we could persuade ourselves that it was still the
twilight-hour. We kept no written record of the merry sayings and
witty repartees and “capital” stories of those impromptu
conversaziones, but they are all stored up in our memories,—other,
and holier passages of our intercourse, where they will be yet more
faithfully kept—in our hearts.
If I am disposed to dwell at unreasonable length upon details that
seem vapid and irrelevant to any other readers, I cry them,
“pardon.” The lapse may be overlooked in one whose life cannot
show many such peaceful seasons; to whom the time and
opportunity to renew health and youth beside such still waters had
not been granted in two decades.
Rome was rest. Geneva was recuperation. I have likened the air
of Switzerland to iced champagne. But the buoyancy begotten by it
had no reaction: the vigor was stable. I had not quite appreciated
this fact when, at Lucerne, I talked with fair tourists from my own
land who “would have died of fatigue,” if compelled to walk a couple
of miles, at home, yet boasted, and truly, of having tramped up the
Rigi and back—a distance of three leagues. But when I walked upon
my own feet into Geneva after an afternoon at Ferney, and
experienced no evil effects from the feat, we began to discredit
scientific analyses, dealing with the preponderance of ozone in the
atmosphere, and to revert to tales of fountains of perpetual youth
and the Elixir of Life.
The town of Ferney is a mean village four miles-and-a-half from
Geneva, and over the French frontier. The château is half-a-mile
further;—a square, two-storied house set in extensive and
handsome grounds, gardens, lawn, park and wood. It is now the
property of a French gentleman who uses it as a country-seat, his
chief residence being in Paris. A liveried footman opened the gate at
the clang of the bell and showed two apartments that remain as
Voltaire left them. These are on the first floor, the entrance-hall, or
salon, being the largest. The floor is of polished wood inlaid in a
cubic pattern. An immense stove of elaborate workmanship stands
against the left wall; a monument of black and gray marble in a
niche to the right. A tablet above the urn on the top of this odd
construction is inscribed:—
“Mon esprit est partout,
Mon cœur est ici.”
Below is the very French legend:—“Mes manes sont consolés,
puisque mon cœur est au milieu de vous.”
“The stove of Voltaire! His monument!” pronounced the servant in
slow, distinct accents.
“But his heart is not really there?”
“But no, monsieur. He is interred in Paris. Madame comprehends
that this is only an epitaph.”
Inferentially,—a lie.
Pictures hung around the room; one remarkable etching of
“Voltaire and his friends;” old engravings and some paintings of little
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!

textbookfull.com

You might also like