(Download PDF) Learning Network Programming With Java 1St Edition Richard M Reese 2 Ebook Online Full Chapter

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 52

Learning Network Programming with

Java 1st Edition Richard M Reese


Visit to download the full and correct content document:
https://ebookmeta.com/product/learning-network-programming-with-java-1st-edition-ri
chard-m-reese-2/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Learning Network Programming with Java 1st Edition


Richard M Reese

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

Neural Network Programming with Java Second Edition


Fabio M. Soares

https://ebookmeta.com/product/neural-network-programming-with-
java-second-edition-fabio-m-soares/

Learning Reactive Programming with Java 8 1st Edition


Nickolay Tsvetinov

https://ebookmeta.com/product/learning-reactive-programming-with-
java-8-1st-edition-nickolay-tsvetinov/

Learning Java An Introduction to Real World Programming


with Java 5th Edition Marc Loy Patrick Niemeyer Daniel
Leuck

https://ebookmeta.com/product/learning-java-an-introduction-to-
real-world-programming-with-java-5th-edition-marc-loy-patrick-
niemeyer-daniel-leuck/
Learning Java Programming in Clara‘s World Anton
Bogdanovych

https://ebookmeta.com/product/learning-java-programming-in-
claras-world-anton-bogdanovych/

Beginning Programming with Java For Dummies Barry Burd

https://ebookmeta.com/product/beginning-programming-with-java-
for-dummies-barry-burd/

Network Programming with Go Language 2nd Edition Ronald


Petty

https://ebookmeta.com/product/network-programming-with-go-
language-2nd-edition-ronald-petty/

Getting Skilled with Java 1st Edition M Rashid Raza

https://ebookmeta.com/product/getting-skilled-with-java-1st-
edition-m-rashid-raza/

Getting Skilled with Java 1st Edition M Rashid Raza

https://ebookmeta.com/product/getting-skilled-with-java-1st-
edition-m-rashid-raza-2/
Table of Contents
Learning Network Programming with Java
Credits
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Network Programming
Network addressing using the InetAddress class
NIO support
Using the URLConnection class
Using the URLConnection class with buffers and channels
The client/server architecture
Creating a simple echo server
Creating a simple echo client
Using Java 8 to support the echo server and client
UDP and multicasting
Creating a multicast server
Creating the multicast client
Scalability
Creating a threaded server
Using the threaded server
Security
Creating a SSL server
Creating an SSL client
Generating secure keys
Summary
2. Network Addressing
Networking basics
Understanding network basics
Network architectures and protocols
Using the NetworkInterface class
Getting a MAC address
Getting a specific MAC address
Getting multiple MAC addresses
Network addressing concepts
URL/URI/URN
Using the URI class
Creating URI instances
Splitting apart a URI
Using the URL class
Creating URL instances
Splitting apart a URL
IP addresses and the InetAddress class
Obtaining information about an address
Address scoping issues
Testing reachability
Introducing the Inet4Address
Private addresses in IPv4
IPv4 address types
The Inet4Address class
Special IPv4 addresses
Introducing the Inet6Address class
Private addresses in IPv6
The Inet6Address class
Special IPv6 addresses
Testing for the IP address type
Using IPv4-compatible IPv6 addresses
Controlling network properties
Summary
3. NIO Support for Networking
Java NIO
Introduction to buffers
Using channels with a time server
Creating a time server
Creating a time client
The chat server/client applications
The chat server
The chat client
Server/client interaction
The HelperMethods class
Handling variable length messages
Running the chat server/client application
Handling multiple clients
The parts server
The parts client handler
The parts client
Running the parts client/server
Asynchronous socket channels
Creating the asynchronous server socket channel server
Creating the asynchronous socket channel client
Other buffer operations
Bulk data transfer
Using a view
Using read-only buffers
Controlling socket options
Summary
4. Client/Server Development
The HTTP protocol structure
The nature of HTTP messages
Initial request line format
Header lines
Message body
Client/Server interaction example
Java socket support for HTTP client/server applications
Building a simple HTTP server
Building a simple HTTP client
Client/server development using standard Java classes
Using the HttpURLConnection class
URL encoding
Using the HTTPServer class
Implementing a simple HTTPServer class
Managing response headers
Open source Java HTTP servers
Server configuration
Handling cookies
Summary
5. Peer-to-Peer Networks
P2P functions/characteristics
Applications-based P2P networks
Java support for P2P applications
Distributed hash tables
DHT components
DHT implementations
Using JDHT
Using FreePastry
The FreePastry demonstration
Understanding the FreePastryExample class
Understanding the FreePastryApplication class
Sending a message to a specific node
Summary
6. UDP and Multicasting
Java support for UDP
TCP versus UDP
UDP client/server
The UDP server application
The UDP client application
The UDP client/server in action
Channel support for UDP
The UDP echo server application
The UDP echo client application
The UDP echo client/server in action
UDP multicasting
The UDP multicast server
The UDP multicast client
The UDP multicast client/server in action
UDP multicasting with channels
The UDP channel multicast server
The UDP channel multicast client
The UDP channel multicast client/server in action
UDP streaming
The UDP audio server implementation
The UDP audio client implementation
Summary
7. Network Scalability
Multithreaded server overview
The thread-per-request approach
The thread-per-request server
The thread-per-request client
The thread-per-request applications in action
Thread-per-connection approach
The thread-per-connection server
The thread-per-connection client
The thread-per-connection applications in action
Thread pools
The ThreadPoolExecutor class characteristics
Simple thread pool server
Simple thread pool client
The thread pool client/server in action
Thread pool with Callable
Using a Callable
Using a Future
Using the HttpServer executor
Using a selector
Creating the selector
Registering a channel
Using the selector to support a time client/server
The channel time server
The date and time client application
The date and time server/client in action
Handling network timeouts
Summary
8. Network Security
Security
Secure communication terminology
Encryption basics
Symmetric encryption techniques
Generating a key
Encrypting text using a symmetric key
Decrypting text
Asymmetric encryption techniques
Generating and saving asymmetric keys
Encrypting/decrypting text using an asymmetric key
Saving asymmetric keys to a file
Creating a keystore
Creating and maintaining a keystore with keytool
Keytool command-line arguments
Creating and maintaining a keystore with Java
Symmetric encryption client/server
Symmetric server application
Symmetric client application
Symmetric client/server in action
Asymmetric encryption client/server
Asymmetric server application
Asymmetric client application
Asymmetric client/server in action
TLS/SSL
SSL server
SSL client
SSL client/server in action
Secure hash functions
Summary
9. Network Interoperability
Byte order in Java
Interfacing with other languages
Interfacing with JVM based languages
Interfacing with non-JVM languages
Communication through simple sockets
The Java server
The C# client
The client/server in action
Interoperability through middleware
Creating a RESTful service
Testing the RESTful service
Creating a RESTful client
Summary
Index
Learning Network Programming with Java
Learning Network Programming with Java
Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be
caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: December 2015

Production reference: 1141215

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78588-547-1

www.packtpub.com
Credits
Author

Richard M Reese

Reviewer

Daniel MÜHLBACHLER

Commissioning Editor

Veena Pagare

Acquisition Editors

Vivek Anantharaman

Rahul Nair

Content Development Editor

Arshiya Ayaz Umer

Technical Editor

Humera Shaikh

Copy Editor

Priyanka Ravi

Project Coordinator

Shipra Chawhan

Proofreader

Safis Editing

Indexer

Monica Ajmera Mehta

Production Coordinator

Nilesh Mohite

Cover Work
Nilesh Mohite
About the Author
Richard M Reese has worked in both industry and academia. For 17 years, he worked in
the telephone and aerospace industries, serving in several capacities, including research
and development, software development, supervision, and training. He currently teaches
at Tarleton State University, where he has the opportunity to apply his years of industry
experience to enhance his teaching.

Richard has written several Java books and a C Pointer book. He uses a concise and easy-
to-follow approach to topics at hand. His Java books have addressed EJB 3.1, updates to
Java 7 and 8, certification, functional programming, jMonkeyEngine, and natural language
processing.

I would like to thank my daughter, Jennifer, for her numerous reviews and
contributions; my wife, Karla, for her continued support; and to the staff of Packt for
their work in making this a better book.
About the Reviewer
Daniel MÜHLBACHLER got interested in computer science shortly after entering high
school, where he later developed web applications as part of a scholarship system for
outstanding pupils.

He has a profound knowledge of web development (PHP, HTML, CSS/LESS, and


AngularJS), and has worked with a variety of other programming languages and systems,
such as Java/Groovy, Grails, Objective-C and Swift, Matlab, C (with Cilk), Node.js, and
Linux servers.

Furthermore, he works with some database management systems based on SQL, and
also some NoSQL systems, such as MongoDB, and SOLR. This is also reflected in several
projects that he is currently involved in at Catalysts GmbH.

After studying abroad as an exchange student in the United Kingdom, he completed his
bachelor's degree at Johannes Kepler University in Linz, Austria, with a thesis on aerosol
satellite data processing for mobile visualization. This is where he also became familiar
with processing large amounts of data.

Daniel enjoys solving challenging problems and is always keen on working with new
technologies, especially related to the fields of big data, functional programming,
optimization, and NoSQL databases.

More detailed information about his experience, as well as his contact details, can be
found at www.muehlbachler.org and www.linkedin.com/in/danielmuehlbachler.
www.PacktPub.com
Support files, eBooks, discount offers, and more
For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as
a print book customer, you are entitled to a discount on the eBook copy. Get in touch with
us at <service@packtpub.com> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for
a range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by Packt


Copy and paste, print, and bookmark content
On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Preface
The world is becoming interconnected on an unprecedented scale with more services
being provided on the Internet. Applications ranging from business transactions to
embedded applications, such as those found in refrigerators, are connecting to the
Internet. With isolated applications no longer being the norm, it is becoming increasingly
important for applications to be network enabled.

The goal of this book is to provide the reader with the necessary skills to develop Java
applications that connect and work with other applications and services across a network.
You will be introduced to a wide range of networking options that are available using
Java, which will enable you to develop applications using the appropriate technology for
the task at hand.
What this book covers
Chapter 1, Getting Started with Network Programming, introduces the essential network
terminology and concepts. The networking support that Java provides is illustrated with
brief examples. A simple client/server application is presented along with a threaded
version of the server.

Chapter 2, Network Addressing, explains how nodes on a network use addresses. How
Java represents these addresses is introduced along with support for IPv4 and IPv6. This
chapter also covers how Java can configure various network properties.

Chapter 3, NIO Support for Networking, explains how the NIO package provides support
for communication using buffers and channels. These techniques are illustrated with a
client/server application. The support that NIO provides for asynchronous communication
is also demonstrated.

Chapter 4, Client/Server Development, covers how HTTP is an important and widely-used


protocol. Java provides support for this protocol in a variety of ways. These techniques
are illustrated along with a demonstration of how cookies are handled in Java.

Chapter 5, Peer-to-Peer Networks, discusses how peer-to-peer networks provide a flexible


alternative to the traditional client/server architecture. The basic peer-to-peer concepts
are introduced along with demonstrations of how Java supports this architecture.
FreePastry is used to illustrate one open source peer-to-peer solution framework.

Chapter 6, UDP and Multicasting, explains how UDP is an alternative to TCP. It provides a
less reliable but more efficient way for applications to communicate across the Internet.
Java's extensive support for this protocol is demonstrated, including NIO support, and
how UDP can support streaming media.

Chapter 7, Network Scalability, explains how, as more demands are placed on a server,
systems need to scale to address these demands. Several threading techniques
supporting this need are demonstrated, including thread pools, futures, and the NIO's
selector.

Chapter 8, Network Security, discusses how applications need to protect against a variety
of threats. This is supported in Java using encryption and secure hashing techniques.
Symmetric and asymmetric encryption techniques are illustrated. In addition, the use of
TLS/SSL is demonstrated.

Chapter 9, Network Interoperability, covers how Java applications may need to exchange
information with other applications that are written in different languages. The issues that
impact an application's interoperability are examined, including byte order.
Communication between different implementations is demonstrated using sockets and
middleware.
What you need for this book
Java SDK 1.8 is needed for the network programming examples that are encountered in
the book. An IDE, such as NetBeans or Eclipse, is recommended. NetBeans IDE 8.0.2 EE
edition is used to illustrate the development of a web service.
Who this book is for
This book is for developers who are already proficient in Java and want to learn how to
develop network-enabled Java applications. Familiarity with basic Java and object-
oriented programming concepts is all that is needed. You will learn the basics of network
programming and how to use a multitude of different sockets to create secure and
scalable applications.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds
of information. Here are some examples of these styles and an explanation of their
meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The
SSLSocketFactory class' getDefault returns an SSLSocketFactory instance whose
createSocket creates a socket that is connected to the secure echo server."

A block of code is set as follows:

public class ThreadedEchoServer implements Runnable {


private static Socket clientSocket;

public ThreadedEchoServer(Socket clientSocket) {


this.clientSocket = clientSocket;
}
...
}

Any command-line input or output is written as follows:

Enter keystore password:


Re-enter new password:
What is your first and last name?
[Unknown]: First Last
What is the name of your organizational unit?
[Unknown]: packt
What is the name of your organization?
[Unknown]: publishing
What is the name of your City or Locality?
[Unknown]: home
What is the name of your State or Province?
[Unknown]: calm
What is the two-letter country code for this unit?
[Unknown]: me
Is CN=First Last, OU=packt, O=publishing, L=home, ST=calm, C=me
correct?
[no]: y
Enter key password for <mykey>
(RETURN if same as keystore password):

New terms and important words are shown in bold. Words that you see on the screen, for
example, in menus or dialog boxes, appear in the text like this: "Once NetBeans has been
installed, start it and then create a new project from the File | New Project… menu item."

Note
Warnings or important notes appear in a box like this.

Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or disliked. Reader feedback is important for us as it helps us
develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the


book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help
you to get the most from your purchase.

Downloading the example code


You can download the example code files from your account at http://www.packtpub.com
for all the Packt Publishing books you have purchased. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to have the files
e-mailed directly to you.

Downloading the color images of this book


We also provide you with a PDF file that has color images of the screenshots/diagrams
used in this book. The color images will help you better understand the changes in the
output. You can download this file from:
https://www.packtpub.com/sites/default/files/downloads/LearningNetworkProgrammingwi
thJava_Graphics.pdf.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you could report this to us. By doing so, you can save
other readers from frustration and help us improve subsequent versions of this book. If
you find any errata, please report them by visiting http://www.packtpub.com/submit-
errata, selecting your book, clicking on the Errata Submission Form link, and entering the
details of your errata. Once your errata are verified, your submission will be accepted and
the errata will be uploaded to our website or added to any list of existing errata under the
Errata section of that title.

To view the previously submitted errata, go to


https://www.packtpub.com/books/content/support and enter the name of the book in the
search field. The required information will appear under the Errata section.

Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At
Packt, we take the protection of our copyright and licenses very seriously. If you come
across any illegal copies of our works in any form on the Internet, please provide us with
the location address or website name immediately so that we can pursue a remedy.

Please contact us at <copyright@packtpub.com> with a link to the suspected pirated


material.
We appreciate your help in protecting our authors and our ability to bring you valuable
content.

Questions
If you have a problem with any aspect of this book, you can contact us at
<questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. Getting Started with Network
Programming
Access to networks (the Internet in particular) is becoming an important and often
necessary feature of applications. Applications frequently need to access and provide
services. As the Internet of Things (IoT) connects more and more devices, understanding
how to access networks becomes crucial.

The important factors that have been the driving forces for more network applications
include the availability of faster networks with greater bandwidth. This has made it
possible to transmit wider ranges of data, such as video streams. In recent years, we
have seen an increase in connectivity, whether it has been for new services, more
extensive social interactions, or games. Knowing how to develop network applications is
an important development skill.

In this chapter, we will cover the basics of Network programming:

Why networking is important


The support that Java provides
Simple programs to address basic network operations
Basic networking terminology
A simple server/client application
Using a thread to support a server

Throughout this book, you will be exposed to many network concepts, ideas, patterns,
and implementation strategies using both older and newer Java technologies. Network
connections occur at a low level using sockets, and at a much higher level using a
multitude of protocols. Communications can be synchronous requiring careful
coordination of requests and responses, or they can be asynchronous where other
activities are performed until the response has been submitted.

These and other concepts are addressed through a series of chapters, each focusing on a
specific topic. The chapters complement each other by elaborating on concepts that were
previously introduced, whenever possible. Numerous code examples are used whenever
possible to further your understanding of the topic.

Central to accessing a service is knowing or discovering its address. This address may be
human readable, such as www.packtpub.com, or in the form of an IP address such as
83.166.169.231. Internet Protocol (IP) is a low-level addressing scheme that is used to
access information on the Internet. Addressing has long used IPv4 to access resources.
However, these addresses are all but gone. The newer IPv6 is available to provide a
larger range of addresses. The basics of network addressing and how they can be
managed in Java is the focus of Chapter 2, Network Addressing.
The intent of network communication is to transfer information to and from other
applications. This is facilitated using buffers and channels. Buffers hold information
temporarily until it can be processed by an application. Channels are an abstraction that
simplifies communications between applications. The NIO and NIO.2 packages provide
much of the support for buffers and channels. We will explore these techniques along
with other techniques, such as blocking and non-blocking IO, in Chapter 3, NIO Support
for Networking.

Services are provided by servers. An example of this is the simple echo server, which
retransmits what it was sent. More sophisticated servers, such as HTTP servers, can
support extensive services to meet a wide range of needs. The client/server model and its
Java support are covered in Chapter 3, NIO Support for Networking.

Another service model is the peer-to-peer (P2P) model. In this architecture, there is no
central server, but rather a network of applications that communicate to provide a service.
This model is represented by applications, such as BitTorrent, Skype, and BBC's iPlayer.
While much of the support that is required for the development of these types of
applications is beyond the scope of this book, Chapter 4, Client/Server Development,
explores P2P issues and the support provided by Java and JXTA.

IP is used at a low level to send and receive packets of information across a network. We
will also demonstrate the use of User Datagram Protocol (UDP) and Transmission Control
Protocol (TCP) communication protocols. These protocols are layered on top of IP. UDP is
used to broadcast short packets or messages with no guarantee of reliable delivery. TCP
is used more commonly and provides a higher level of service than that of UDP. We will
cover the use of these related technologies in Chapter 5, Peer-to-Peer Networks.

A service will often be faced with varying levels of demand placed on it due to a number
of factors. Its load may vary by the time of the day. As it becomes more popular, its
overall demand will also increase. The server will need to scale to meet increases and
decreases in its load. Threads and thread pools have been used to support this effort.
These and other technologies are the focus of Chapter 6, UDP and Multicasting.

Increasingly, applications need to be secure against attacks by hackers. When it is


connected to a network, this threat increases. In Chapter 7, Network Scalability, we will
explore many of the techniques available to support secure Java applications. Among
these is the Secure Socket Level (SSL), and how Java supports it.

Applications rarely work in isolation. Hence, they need to use networks to access other
applications. However, not all applications are written in Java. Networking with these
applications can pose special problems ranging from how the bytes of a data type are
organized to the interface supported by the application. It is common to work with
specialized protocols, such as HTTP, and WSDL. The last chapter of this book examines
these issues from a Java perspective.

We will demonstrate both older and newer Java technologies. Understanding the older
technologies may be necessary in order to maintain older code, and it can provide insight
into why the newer technologies were developed. We will also complement our examples
using many of the Java 8 functional programming techniques. Using Java 8 examples
along with pre-Java 8 implementations, we can learn how to use Java 8 and be better
informed as to when it can and should be used.

It is not the intent to fully explain the newer Java 8 technologies, such as lambda
expressions, and streams. However, the use of Java 8 examples will provide an insight
into how they can be used to support networked applications.

The remainder of this chapter touches on many of the network technologies that are
explored in this book. You will be introduced to the basics of these techniques, and you
should find them easy to understand. However, there are a few places where time does
not permit us to fully explore and explain these concepts. These issues will be addressed
in subsequent chapters. So, let's begin our exploration with network addressing.

Network addressing using the InetAddress class


An IP address is represented by the InetAddress class. Addresses can be either unicast
where it identifies a specific address, or it can be multicast, where a message is sent to
more than one address.

The InetAddress class has no public constructors. To get an instance, use one of the
several static get type methods. For example, the getByName method takes a string
representing the address as shown next. The string in this case is a Uniform Resource
Locator (URL):

InetAddress address =
InetAddress.getByName("www.packtpub.com");
System.out.println(address);

Tip
Downloading the example code

You can download the example code files for all Packt books you have purchased
from your account at http://www.packtpub.com. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to have the
files e-mailed directly to you.

This will display the following results:

www.packtpub.com/83.166.169.231

The number attached to the end of the name is the IP address. This address uniquely
identifies an entity on the Internet.
If we need other information about the address, we can use one of several methods, as
illustrated here:

System.out.println("CanonicalHostName: "
+ address.getCanonicalHostName());
System.out.println("HostAddress: " +
address.getHostAddress());
System.out.println("HostName: " + address.getHostName());

This produces the following output when executed:

CanonicalHostName: 83.166.169.231

HostAddress: 83.166.169.231

HostName: www.packtpub.com

To test to see whether this address is reachable, use the isReachable method as shown
next. Its argument specifies how long to wait before deciding that the address cannot be
reached. The argument is the number of milliseconds to wait:

address.isReachable(10000);

There are also the Inet4Address and Inet6Address classes that support IPv4 and IPv6
addresses, respectively. We will explain their use in Chapter 2, Network Addressing.

Once we have obtained an address, we can use it to support network access, such as
with servers. Before we demonstrate its use in this context, let's examine how we can
obtain and process data from a connection.
NIO support
The java.io, java.nio, and java.nio subpackages provide most of the Java support for
IO processing. We will examine the support that these packages provide for network
access in Chapter 3, NIO Support for Networking. Here, we will focus on the basic
aspects of the java.nio package.

There are three key concepts used in the NIO package:

Channel: This represents a stream of data between applications


Buffer: This works with a channel to process data
Selector: This is a technology that allows a single thread to handle multiple channels

A channel and a buffer are typically associated with each other. Data may be transferred
from a channel to a buffer or from a buffer to a channel. The buffer, as its name implies,
is a temporary repository for information. The selector is useful in supporting application
scalability, and this will be discussed in Chapter 7, Network Scalability.

There are four primary channels:

FileChannel:This works with a file


DatagramChannel: This supports UDP communications
SocketChannel: This is used with a TCP client
ServerSocketChannel: This is used with a TCP server

There are several buffer classes that support primitive data types, such as character,
integer, and float.

Using the URLConnection class


A simple way of accessing a server is to use the URLConnection class. This class
represents a connection between an application and a URL instance. A URL instance
represents a resource on the Internet.

In the next example, a URL instance is created for the Google website. Using the URL
class' openConnection method, a URLConnection instance is created. A BufferedReader
instance is used to read lines from the connection that is then displayed:

try {
URL url = new URL("http://www.google.com");
URLConnection urlConnection = url.openConnection();
BufferedReader br = new BufferedReader(
new InputStreamReader(
urlConnection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
} catch (IOException ex) {
// Handle exceptions
}

The output is rather lengthy, so only part of the first line is shown here:

<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" ...

The URLConnection class hides some of the complexity of accessing HTTP servers.

Using the URLConnection class with buffers and channels


We can rework the previous example to illustrate the use of channels and buffers. The
URLConnection instance is created as before. We will create a ReadableByteChannel
instance and then a ByteBuffer instance, as illustrated in the next example. The
ReadableByteChannel instance allows us to read from the site using its read method. A
ByteBuffer instance receives data from the channel and is used as the argument of the
read method. The buffer created holds 64 bytes at a time.

The read method returns the number of bytes read. The ByteBuffer class' array method
returns an array of bytes, which is used as the argument of the String class' constructor.
This is used to display the data read. The clear method is used to reset the buffer so that
it can be used again:

try {
URL url = new URL("http://www.google.com");
URLConnection urlConnection = url.openConnection();
InputStream inputStream = urlConnection.getInputStream();
ReadableByteChannel channel =
Channels.newChannel(inputStream);
ByteBuffer buffer = ByteBuffer.allocate(64);
String line = null;
while (channel.read(buffer) > 0) {
System.out.println(new String(buffer.array()));
buffer.clear();
}
channel.close();
} catch (IOException ex) {
Another random document with
no related content on Scribd:
pointed out by Paré and Le Dran, fractures do sometimes take
place without being accompanied by all these symptoms, still
there can be no doubt that as a general rule the doctrine of
Celsus is correct, and that, at all events, a case is to be treated as
serious in which these symptoms occur. With regard to one of the
characteristics of a fracture, thus noticed by Celsus, a modern
authority of great experience, but little acquaintance with ancient
learning, observes, “Blood flowing from the nose and ears is a
symptom attending fracture of the skull. It may be consequent on
mere concussion, a vibration which ruptures the membranes; but
oftener it is a consequence of fissure across the bone.” (Institutes
of Surgery, by Sir Charles Bell, vol., i, p. 173.)
[796] The separation of the bones at a suture, usually called
diastasis, is noticed in the annotations on § 8. I have also alluded,
in my analysis of the Fifth Book of the Epidemics, to the case in
which the author, generally supposed by ancient authorities to be
Hippocrates, mistook a suture for a fracture of the skull. See
Epidem. v., 14; and Celsus, viii., 4.
[797] On the terms which occur parenthetically, the philological
reader may consult the note of Stephanus, contained in the
edition of Erotian by Franzius, under ἑδράιως. I may here remark,
that it is difficult to account for the frequent repetition of these
words in parentheses.
[798] It will be remarked that, as a general rule, Hippocrates
forbids us to apply the trepan at the sutures, but, notwithstanding
this prohibition, it would appear to have been departed from in
two cases related in the Sixth Book of the Epidemics. (See § 27
and 28.) The rule, however, to avoid the application of the trepan
at the sutures, was generally observed by nearly all the modern
authorities down to Pott, and even he admits that the sutures
should be avoided when the trephine may with equal utility be set
on any other part. Louis, in a paper lately reprinted from the
Memoirs of the Royal Academy of Surgery, by the Sydenham
Society, gives an interesting examination of the doctrine of the
ancient and modern authors on this rule of practice. Most of the
authorities quoted by him are averse to the application of the
trepan over sutures, except when very urgently required. C.
Porralius, in his marginal notes on Arantius’s Commentary on this
work of Hippocrates, assigns three reasons for avoiding the
sutures in this operation: 1st, because the bone is weak at that
place; 2dly, because the membrane there being in close
connection with the bone, is in danger of being injured; 3dly,
because, by the contraction of the callus, the transpiration there
will be stopped. The last of these reasons is based on the
physiological doctrine of the ancient authorities respecting the
uses of the sutures, one of which was, to permit transpiration from
the brain. See Galen, de Usu Partium, ix., 1, 2.
[799] Our author, it will be remarked, forbids liquid
applications, tents, cataplasms, and bandages, in wounds of the
head. He seems to have approved most of things of a drying
nature. The other authorities would appear to differ considerably
in their views regarding the proper principles upon which wounds
on the head are to be treated. Celsus directs us, after laying bare
the dura mater by trepanning, to apply strong vinegar to it, and
when the membrane is inflamed, he approves of tepid rose-water.
(viii., 4.) Paulus Ægineta, after the operation of trepanning, directs
a piece of cloth, or small ball of wool dipped in oil, to be applied to
the part. I believe they all agreed in rejecting sutures. See Galen,
de Med. sec. Genera III.
[800] Hippocrates would seem to hold the fanciful idea, that
the forehead is environed by the rest of the head, and that afflux
of blood takes place from the parts around to it. Scaliger rejects
this passage as containing a doctrine wholly unworthy of our
author.
[801] The danger of incisions, in the temporal region, is
adverted to in several parts of the Hippocratic Collection, as in the
work On the Articulations, in the Prorrhetics, and the Coan
Prænotions. Even at the present day, when the treatment of
hemorrhage is better understood than in the days of the great
Fathers of Grecian medicine, a large incision in that quarter is
regarded with considerable apprehension. Convulsion, that is to
say, tetanus, was supposed to be the frequent, if not the
invariable, result of a wound in the temporal muscle. Pott, indeed,
contends that lock-jaw is not necessarily produced by a wound
there; he admits, however, that the application of the trepan to the
temple is not often successful, but the reason of this he contends
is, that in these fractures the breach generally extends to the
base of the skull (§ 5). Quesnay, however, inclines to support the
views of Hippocrates. (On the Use of the Trepan, p. 15, Syd. Soc.
edit.) Scultet, in like manner, pronounces decidedly that a wound
in the temple is a very dangerous affair. (Armam. Chirurg. Tabl.
xxxi.)
[802] The maza was evidently a poultice prepared with barley-
meal and vinegar, or water. See the Annotations on the treatise
On Ancient Medicine.
[803] Celsus translates this passage as follows: “At si ne tum
quidem rima manifesta est, inducendum supra os atramentum
scriptorium est, deinde scalpro id deradendum; nigritiem enim
continet, si quid fissum est.” (viii., 4.) Arantius properly remarks,
that the ancient ink must not be confounded with the modern,
which is composed principally of copperas and galls. It was, no
doubt, the milder kind prepared from the soot of pines with gum
which was used in this case. On the writing-ink of the ancients,
see Dioscorides (M. M., v., 182) and Pliny (H. N., xxxv., 6).
[804] The text in the beginning of this paragraph is in a very
unsatisfactory state. It seems pretty clear, however, that in this
place our author describes caries of the bone brought on by an
unhealthy state of the integuments. The description—allowance
being made for the corruption of the text—is sufficiently distinct,
and most probably has reference to that condition of the parts
which is so graphically described by Pott as forming “a puffy,
circumscribed, indolent tumour of the scalp, and a spontaneous
separation of the pericranium from the skull under such tumour.”
[805] Our author in this place would appear to treat of incipient
hernia cerebri, as immediately before he treats of fungous ulcers
on the pericranium. Galen in like manner, praises powerfully
dessicant medicines upon the authority of Meges the Sidonian,
who, he says, had great experience in these cases. He speaks of
the plaster called Isis as being a most efficacious application to
the dura mater, when laid bare. Its principal ingredients are of an
escharotic and detergent nature, such as squama æris, burnt
copper, ammoniac salts, myrrh, aloes, and the like. See Paulus
Ægineta, Vol. III., p. 564. Galen concludes his remarks on this
subject with stating that, before getting into an inflamed state, the
dura mater, as being of a dry nature, endures the most powerful
medicines. (Meth. Med., vi., at the end.)
[806] This description of a piece of bone which is going to
exfoliate, is remarkably correct. Compare it with the following
narrative: “A girl of ten or twelve years of age was struck on the
head by an iron rod falling on her; the blow caused no wound,
and the young woman was soon well, with the exception of a
fixed pain of no great extent, which remained over one of the
parietal bones. The pain continued for several years. M.
Mareschal, who was at last consulted, considered it necessary to
trepan. He exposed the bone at the painful part, and applied one
crown of a trepan; he observed, that the bone, when sawed,
appeared dry, like a skull that had been buried.” (Quesnay, on the
Use of the Trepan.) This agrees excellently with the description
given by Hippocrates. It is to be regretted, however, that the text
here; as far as regards one word ἀποστρακὸς, is in a very
unsatisfactory state. The conjectural emendation of Schneider
(ἀπεσκληκὸς) seems to be a plausible emendation, but it is not
adopted by Littré.
[807] Our author delivers the same doctrine in the work On the
Articulations, and states that extensive fractures of the bones are
often less dangerous than others which appear not so formidable.
I need scarcely remark that modern experience has confirmed the
truth of this position. How often has it been seen that one patient
died from a slight injury to the skull, while another recovered from
an extensive fracture of it? Mr. Guthrie appears in so far to agree
in opinion with our author, that extensive fractures are less
dangerous than they appear; he says, “Mr. Keate, who has had
great opportunities for observation in St. George’s Hospital, has
invariably remarked that the symptoms dependent on
extravasation have been less severe in the first instance, in
proportion as the separation of the edges of the fracture have
been greater one from the other, or when the sutures have
yielded to the shock and have been separated. It has been stated
from the earliest antiquity, that the greater the fracture, the less
the concussion of the brain.” (p. 56.) See the Argument.
[808] It will be remarked as a striking feature in our author’s
views of practice in injuries of the head, not to interfere with
fractures attended with depression. See the Argument, where the
rationale of this practice is fully discussed.
[809] Although these directions of our author regarding the
treatment of children be most important, I am not aware that any
other of the ancient authorities has shown his sense of their value
of them by repeating them. It is well known that in children there
is but one table, and that it is very thin. Our author, as remarked
above, does not entirely omit the operation in the case of children,
but uses a small trepan.
[810] The reader will again remark an instance of our author’s
fondness for prognosis, and his observance of the rule at all times
to prevent the surgeon from committing himself by attempting
hopeless cases. Celsus, writing in the same spirit, says, “Ante
omnia scire medicum oportere, quæ vulnera insanabilia sint, quæ
difficilem curationem habeant; ... non attingere, nec subire
speciem ejus, ut occisi, quem sors ipsius intermit.” (v., 26.)
[811] This is an opinion held by all the ancient authorities.
Some interesting cases in point are related in the First Book of
the Continens of Rhazes. It was explained on the principle that
the cerebral nerves decussate. (See Aretæus, on the Causes of
Disease, i., 7.) Modern experience, in the main, is in accordance
with the ancient on this point. Paralysis has generally been found
on the opposite side to that which has received the injury. See
Thomson’s Observations, etc., p. 52; Larrey’s Mem. de Chirurg.,
iv., p. 180; Hennen’s Principles, p. 301.
[812] This passage is thus translated by Celsus: “Si sub prima
curatione febris intenditur, brevesque somni, et iidem per summa
tumultuosi sunt, ulcus madet, neque alitur, et in cervicibus
glandulæ oriuntur, magni dolores sunt, cibique super hoc
fastidium increscit, tum demum ad manum scalprumque
veniendum est.” (vii., 4.)
[813] The practice advocated in this paragraph is alluded to by
Paulus Ægineta, in his chapter on Fractures of the Skull. (vi., 90.)
[814] The operation here described by our author is the more
deserving of attention, as it appears to have been peculiar to him.
It is not described by Celsus, Paulus Ægineta, Albucasis, nor any
one of the ancient authorities, as far as I can find; neither am I
aware of its having been attempted in modern times. The object
of it, however, seems to be very rational, namely, to avoid doing
serious injury to the dura mater by tearing the bone forcibly from it
at once.
[815] The instrument here used is named πρίων χαρακτὸς;
and, as far as I can see, was the same as the modiolus of Celsus,
and the χοινικὶς of the later authorities. It would certainly appear to
have been a circular saw, and consequently not unlike our
modern trephine. See the figures and the Argument.
[816] The following sentence, taken from Sir Charles Bell’s
description of the operation, looks like a translation of this
passage of Hippocrates; but it is well known that our English
surgeon was not guilty of reading Greek! “Withdraw your trephine
from time to time, brush it, and run the flat probe round the
circular cut.” The specillum of the ancient surgeons was, in most
respects, not unlike our modern probe.
[817] The meaning here would seem to be, that the bone does
not extend so deep as might be supposed. See Foës, Œcon.
Hippoc., under ἐπιπολαιότερον ὀστέου.
Transcriber’s Notes:

1. Obvious printers’, punctuation and spelling errors have been corrected


silently.

2. Where hyphenation is in doubt, it has been retained as in the original.

3. Some hyphenated and non-hyphenated versions of the same words have


been retained as in the original.

4. Possible errors in Greek words or phrases have been retained as in original.


*** END OF THE PROJECT GUTENBERG EBOOK THE GENUINE
WORKS OF HIPPOCRATES, VOL. 1 (OF 2) ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree to
abide by all the terms of this agreement, you must cease using
and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it
away or re-use it under the terms of the Project Gutenberg
License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country where
you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like