0% found this document useful (0 votes)
210 views75 pages

Learning Network Programming With Java 1st Edition Richard M Reese - Download The Ebook With All Fully Detailed Chapters

The document promotes the ebook 'Learning Network Programming with Java' by Richard M. Reese, available for download at ebookmeta.com. It outlines the book's content, which covers essential networking concepts, Java's networking capabilities, and various programming techniques for developing network-enabled applications. Additionally, it provides links to other recommended ebooks and information about the author and reviewer.

Uploaded by

zoomawedo
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)
210 views75 pages

Learning Network Programming With Java 1st Edition Richard M Reese - Download The Ebook With All Fully Detailed Chapters

The document promotes the ebook 'Learning Network Programming with Java' by Richard M. Reese, available for download at ebookmeta.com. It outlines the book's content, which covers essential networking concepts, Java's networking capabilities, and various programming techniques for developing network-enabled applications. Additionally, it provides links to other recommended ebooks and information about the author and reviewer.

Uploaded by

zoomawedo
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/ 75

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Learning Network Programming with Java 1st Edition


Richard M Reese

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

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

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/

ebookmeta.com

Neural Network Programming with Java Second Edition Fabio


M. Soares

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

ebookmeta.com

Learning Reactive Programming with Java 8 1st Edition


Nickolay Tsvetinov

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

ebookmeta.com

Smith & Tanagho’s General Urology 19th Edition Jack W.


Mcaninch

https://ebookmeta.com/product/smith-tanaghos-general-urology-19th-
edition-jack-w-mcaninch/

ebookmeta.com
Foundations of Mathematics: A Preparatory Course Guido
Walz

https://ebookmeta.com/product/foundations-of-mathematics-a-
preparatory-course-guido-walz/

ebookmeta.com

Economics of Regulation and Antitrust 5th Edition Viscusi


W Kip Harrington Jr Joseph E Sappington David E M

https://ebookmeta.com/product/economics-of-regulation-and-
antitrust-5th-edition-viscusi-w-kip-harrington-jr-joseph-e-sappington-
david-e-m/
ebookmeta.com

Beginning Power BI 2nd Edition Dan Clark

https://ebookmeta.com/product/beginning-power-bi-2nd-edition-dan-
clark/

ebookmeta.com

Dr Bad Boy 1st Edition Ainsley Booth Sadie Haller

https://ebookmeta.com/product/dr-bad-boy-1st-edition-ainsley-booth-
sadie-haller/

ebookmeta.com

The Book of Oberon: A Sourcebook of Elizabethan Magic


Daniel Harms

https://ebookmeta.com/product/the-book-of-oberon-a-sourcebook-of-
elizabethan-magic-daniel-harms/

ebookmeta.com
FTCE Social Science 6 12 037 Book Online 3rd Edition
Rhonda Atkinson

https://ebookmeta.com/product/ftce-social-science-6-12-037-book-
online-3rd-edition-rhonda-atkinson/

ebookmeta.com
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 <[email protected]> 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


<[email protected]>, 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/LearningNe
tworkProgrammingwithJava_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 <[email protected]> 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 <[email protected]>, 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) {
// Handle exceptions
}

The first line of output is shown next. This produces the same
output as before, but it is restricted to displaying 64 bytes at a time:
<!doctype html><html itemscope=""
itemtype="http://schema.org/We

The Channel class and its derived classes provide an improved


technique to access data found on a network than data provided by
older technologies. We will be seeing more of this class.
The client/server architecture
There are several ways of creating servers using Java. We will
illustrate a couple of simple approaches and postpone a detailed
discussion of these techniques until Chapter 4, Client/Server
Development. Both a client and a server will be created.

A server is installed on a machine with an IP address. It is possible


for more than one server to be running on a machine at any given
time. When the operating system receives a request for a service on
a machine, it will also receive a port number. The port number will
identify the server to where the request should be forwarded. A
server is, thus, identified by its combination of IP address and port
number.

Typically, a client will issue a request to a server. The server will


receive the request and send back a response. The nature of the
request/response and the protocol used for communication is
dependent on the client/server. Sometimes a well-documented
protocol, such as the Hypertext Transfer Protocol (HTTP), is
used. For simpler architectures, a series of text messages are sent
back and forth.

For the server to communicate with an application making a request,


specialized software is used to send and receive messages. This
software is called a socket. One socket is found on the client side,
and the other socket is located on the server side. When they
connect, communication is possible. There are several different types
of sockets. These include datagram sockets; stream sockets, which
frequently use TCP; and raw sockets, which normally work at the IP
level. We will focus on TCP sockets for our client/server application.

Specifically, we will create a simple echo server. This server will


receive a text message from a client and will immediately send it
back to that client. The simplicity of this server allows us to focus on
the client-server basics.
Creating a simple echo server
We will start with the definition of the SimpleEchoServer class as
shown next. In the main method, an initial server message will be
displayed:

public class SimpleEchoServer {


public static void main(String[] args) {
System.out.println("Simple Echo Server");
...
}
}

The remainder of the method's body consists of a series of try blocks


to handle exceptions. In the first try block, a ServerSocket instance
is created using 6000 as its parameter. The ServerSocket class is a
specialized socket that is used by a server to listen for client
requests. Its argument is its port number. The IP of the machine on
which the server is located is not necessarily of interest to the server,
but the client will ultimately need to know this IP address.

In the next code sequence, an instance of the ServerSocket class is


created and its accept method is called. The ServerSocket will block
this call until it receives a request from a client. Blocking means that
the program is suspended until the method returns. When a request
is received, the accept method will return a Socket class instance,
which represents the connection between that client and the server.
They can now send and receive messages:

try (ServerSocket serverSocket = new


ServerSocket(6000)){
System.out.println("Waiting for
connection.....");
Socket clientSocket =
serverSocket.accept();
System.out.println("Connected to client");
...
} catch (IOException ex) {
Other documents randomly have
different content
It is objected that Kossuth did not denounce our slavery. The same
objection has equal strength against the philanthropy of Paul and
Jesus. I shall not dwell on this point. He did denounce American
slavery. The presence of Kossuth was a killing rebuke, his words a
consuming fire to it. The former is still felt as an incurable wound,
and the latter still scorches to the very centre of its vitality. I have it
from high authority, when Kossuth first came upon the soil, and into
the atmosphere of American slavery, his soul was so shocked and
disgusted by its offensiveness, that he proposed to abandon his
mission in those States where it existed, and denounce it
specifically; and was only deterred from doing so, by his sense of
the more comprehensive claims of that mission, which embraced the
utter destruction of all human oppression. I drop this topic with the
remark, that this objection, and all objections to his philanthropy,
within my knowledge, were made antecedent to his inimitable
speech in New York city, in behalf of his mother and sisters, a short
time before he took his departure for Europe. If there is not
Christianity, philanthropy, anti-slavery in that speech, we may
despair of finding it in earth, or even in the heavens. I have never
read anything so representative of heaven’s mercy, or angels’
eloquence, as that. Oh! I wish the world knew it by heart. Methinks
if it did, all wrong and oppression would disappear from among men.
I was going to speak of the future, and of Mazzini, the twin apostle
of liberty, whose exile was wrung from the heart of poor Italy. But
the subject exceeds the brevity which must govern me. These rulers
of the world are linked with the mighty events which are fast
becoming history. From their hiding-places in London, they are
moving and controlling the passions which seem ready to break forth
and obliterate every cruel code under the sun, and hasten the time
when all men shall feel as brethren, and mingle their hearts in
anthems of gratitude and love.
Syracuse, Nov. 14, 1852. John Thomas
THE HEROIC SLAVE.

PART I.
Oh! child of grief, why weepest thou?
Why droops thy sad and mournful brow?
Why is thy look so like despair?
What deep, sad sorrow lingers there?
The State of Virginia is famous in American annals for the
multitudinous array of her statesmen and heroes. She has been
dignified by some the mother of statesmen. History has not been
sparing in recording their names, or in blazoning their deeds. Her
high position in this respect, has given her an enviable distinction
among her sister States. With Virginia for his birth-place, even a
man of ordinary parts, on account of the general partiality for her
sons, easily rises to eminent stations. Men, not great enough to
attract special attention in their native States, have, like a certain
distinguished citizen in the State of New York, sighed and repined
that they were not born in Virginia. Yet not all the great ones of the
Old Dominion have, by the fact of their birth-place, escaped
undeserved obscurity. By some strange neglect, one of the truest,
manliest, and bravest of her children,—one who, in after years, will,
I think, command the pen of genius to set his merits forth, holds
now no higher place in the records of that grand old Commonwealth
than is held by a horse or an ox. Let those account for it who can,
but there stands the fact, that a man who loved liberty as well as did
Patrick Henry,—who deserved it as much as Thomas Jefferson,—and
who fought for it with a valor as high, an arm as strong, and against
odds as great, as he who led all the armies of the American colonies
through the great war for freedom and independence, lives now only
in the chattel records of his native State.
Glimpses of this great character are all that can now be presented.
He is brought to view only by a few transient incidents, and these
afford but partial satisfaction. Like a guiding star on a stormy night,
he is seen through the parted clouds and the howling tempests; or,
like the gray peak of a menacing rock on a perilous coast, he is seen
by the quivering flash of angry lightning, and he again disappears
covered with mystery.
Curiously, earnestly, anxiously we peer into the dark, and wish even
for the blinding flash, or the light of northern skies to reveal him. But
alas! he is still enveloped in darkness, and we return from the
pursuit like a wearied and disheartened mother, (after a tedious and
unsuccessful search for a lost child,) who returns weighed down with
disappointment and sorrow. Speaking of marks, traces, possibles,
and probabilities, we come before our readers.

In the spring of 1835, on a Sabbath morning, within hearing of the


solemn peals of the church bells at a distant village, a Northern
traveller through the State of Virginia drew up his horse to drink at a
sparkling brook, near the edge of a dark pine forest. While his weary
and thirsty steed drew in the grateful water, the rider caught the
sound of a human voice, apparently engaged in earnest
conversation.
Following the direction of the sound, he descried, among the tall
pines, the man whose voice had arrested his attention. “To whom
can he be speaking?” thought the traveller. “He seems to be alone.”
The circumstance interested him much, and he became intensely
curious to know what thoughts and feelings, or, it might be, high
aspirations, guided those rich and mellow accents. Tieing his horse
at a short distance from the brook, he stealthily drew near the
solitary speaker; and, concealing himself by the side of a huge fallen
tree, he distinctly heard the following soliloquy:—
“What, then, is life to me? it is aimless and worthless, and worse
than worthless. Those birds, perched on yon swinging boughs, in
friendly conclave, sounding forth their merry notes in seeming
worship of the rising sun, though liable to the sportsman’s fowling-
piece, are still my superiors. They live free, though they may die
slaves. They fly where they list by day, and retire in freedom at
night. But what is freedom to me, or I to it? I am a slave,—born a
slave, an abject slave,—even before I made part of this breathing
world, the scourge was platted for my back; the fetters were forged
for my limbs. How mean a thing am I. That accursed and crawling
snake, that miserable reptile, that has just glided into its slimy home,
is freer and better off than I. He escaped my blow, and is safe. But
here am I, a man,—yes, a man!—with thoughts and wishes, with
powers and faculties as far as angel’s flight above that hated reptile,
—yet he is my superior, and scorns to own me as his master, or to
stop to take my blows. When he saw my uplifted arm, he darted
beyond my reach, and turned to give me battle. I dare not do as
much as that. I neither run nor fight, but do meanly stand,
answering each heavy blow of a cruel master with doleful wails and
piteous cries. I am galled with irons; but even these are more
tolerable than the consciousness, the galling consciousness of
cowardice and indecision. Can it be that I dare not run away? Perish
the thought, I dare do any thing which may be done by another.
When that young man struggled with the waves for life, and others
stood back appalled in helpless horror, did I not plunge in, forgetful
of life, to save his? The raging bull from whom all others fled, pale
with fright, did I not keep at bay with a single pitch-fork? Could a
coward do that? No,—no,—I wrong myself,—I am no coward. Liberty
I will have, or die in the attempt to gain it. This working that others
may live in idleness! This cringing submission to insolence and
curses! This living under the constant dread and apprehension of
being sold and transferred, like a mere brute, is too much for me. I
will stand it no longer. What others have done, I will do. These trusty
legs, or these sinewy arms shall place me among the free. Tom
escaped; so can I. The North Star will not be less kind to me than to
him. I will follow it. I will at least make the trial. I have nothing to
lose. If I am caught, I shall only be a slave. If I am shot, I shall only
lose a life which is a burden and a curse. If I get clear, (as
something tells me I shall,) liberty, the inalienable birth-right of
every man, precious and priceless, will be mine. My resolution is
fixed. I shall be free.”
At these words the traveller raised his head cautiously and
noiselessly, and caught, from his hiding-place, a full view of the
unsuspecting speaker. Madison (for that was the name of our hero)
was standing erect, a smile of satisfaction rippled upon his
expressive countenance, like that which plays upon the face of one
who has but just solved a difficult problem, or vanquished a
malignant foe; for at that moment he was free, at least in spirit. The
future gleamed brightly before him, and his fetters lay broken at his
feet. His air was triumphant.
Madison was of manly form. Tall, symmetrical, round, and strong. In
his movements he seemed to combine, with the strength of the lion,
a lion’s elasticity. His torn sleeves disclosed arms like polished iron.
His face was “black, but comely.” His eye, lit with emotion, kept
guard under a brow as dark and as glossy as the raven’s wing. His
whole appearance betokened Herculean strength; yet there was
nothing savage or forbidding in his aspect. A child might play in his
arms, or dance on his shoulders. A giant’s strength, but not a giant’s
heart was in him. His broad mouth and nose spoke only of good
mature and kindness. But his voice, that unfailing index of the soul,
though full and melodious, had that in it which could terrify as well
as charm. He was just the man you would choose when hardships
were to be endured, or danger to be encountered,—intelligent and
brave. He had the head to conceive, and the hand to execute. In a
word, he was one to be sought as a friend, but to be dreaded as an
enemy.
As our traveller gazed upon him, he almost trembled at the thought
of his dangerous intrusion. Still he could not quit the place. He had
long desired to sound the mysterious depths of the thoughts and
feelings of a slave. He was not, therefore, disposed to allow so
providential an opportunity to pass unimproved. He resolved to hear
more; so he listened again for those mellow and mournful accents
which, he says, made such an impression upon him as can never be
erased. He did not have to wait long. There came another gush from
the same full fountain; now bitter, and now sweet. Scathing
denunciations of the cruelty and injustice of slavery; heart-touching
narrations of his own personal suffering, intermingled with prayers to
the God of the oppressed for help and deliverance, were followed by
presentations of the dangers and difficulties of escape, and formed
the burden of his eloquent utterances; but his high resolution clung
to him,—for he ended each speech by an emphatic declaration of his
purpose to be free. It seemed that the very repetition of this,
imparted a glow to his countenance. The hope of freedom seemed
to sweeten, for a season, the bitter cup of slavery, and to make it,
for a time, tolerable; for when in the very whirlwind of anguish,—
when his heart’s cord seemed screwed up to snapping tension, hope
sprung up and soothed his troubled spirit. Fitfully he would exclaim,
“How can I leave her? Poor thing! what can she do when I am gone?
Oh! oh! ’tis impossible that I can leave poor Susan!”
A brief pause intervened. Our traveller raised his head, and saw
again the sorrow-smitten slave. His eye was fixed upon the ground.
The strong man staggered under a heavy load. Recovering himself,
he argued thus aloud: “All is uncertain here. To-morrow’s sun may
not rise before I am sold, and separated from her I love. What, then,
could I do for her? I should be in more hopeless slavery, and she no
nearer to liberty,—whereas if I were free,—my arms my own,—I
might devise the means to rescue her.”
This said, Madison cast around a searching glance, as if the thought
of being overheard had flashed across his mind. He said no more,
but, with measured steps, walked away, and was lost to the eye of
our traveller amidst the wildering woods.
Long after Madison had left the ground, Mr. Listwell (our traveller)
remained in motionless silence, meditating on the extraordinary
revelations to which he had listened. He seemed fastened to the
spot, and stood half hoping, half fearing the return of the sable
preacher to his solitary temple. The speech of Madison rung through
the chambers of his soul, and vibrated through his entire frame.
“Here is indeed a man,” thought he, “of rare endowments,—a child
of God,—guilty of no crime but the color of his skin,—hiding away
from the face of humanity, and pouring out his thoughts and
feelings, his hopes and resolutions to the lonely woods; to him those
distant church bells have no grateful music. He shuns the church,
the altar, and the great congregation of christian worshippers, and
wanders away to the gloomy forest, to utter in the vacant air
complaints and griefs, which the religion of his times and his country
can neither console nor relieve. Goaded almost to madness by the
sense of the injustice done him, he resorts hither to give vent to his
pent up feelings, and to debate with himself the feasibility of plans,
plans of his own invention, for his own deliverance. From this hour I
am an abolitionist. I have seen enough and heard enough, and I
shall go to my home in Ohio resolved to atone for my past
indifference to this ill-starred race, by making such exertions as I
shall be able to do, for the speedy emancipation of every slave in the
land.”

PART II.
“The gaudy, blabbling and remorseful day
Is crept into the bosom of the sea;
And now loud-howling wolves arouse the jades
That drag the tragic melancholy night;
Who with their drowsy, slow, and flagging wings
Clip dead men’s graves, and from their misty jaws
Breathe foul contagions, darkness in the air.”

Shakspeare.

Five years after the foregoing singular occurrence, in the winter of


1840, Mr. and Mrs. Listwell sat together by the fireside of their own
happy home, in the State of Ohio. The children were all gone to bed.
A single lamp burnt brightly on the centre-table. All was still and
comfortable within; but the night was cold and dark; a heavy wind
sighed and moaned sorrowfully around the house and barn,
occasionally bringing against the clattering windows a stray leaf from
the large oak trees that embowered their dwelling. It was a night for
strange noises and for strange fancies. A whole wilderness of
thought might pass through one’s mind during such an evening. The
smouldering embers, partaking of the spirit of the restless night,
became fruitful of varied and fantastic pictures, and revived many
bygone scenes and old impressions. The happy pair seemed to sit in
silent fascination, gazing on the fire. Suddenly this reverie was
interrupted by a heavy growl. Ordinarily such an occurrence would
have scarcely provoked a single word, or excited the least
apprehension. But there are certain seasons when the slightest
sound sends a jar through all the subtle chambers of the mind; and
such a season was this. The happy pair started up, as if some
sudden danger had come upon them. The growl was from their
trusty watch-dog.
“What can it mean? certainly no one can be out on such a night as
this,” said Mrs. Listwell.
“The wind has deceived the dog, my dear; he has mistaken the
noise of falling branches, brought down by the wind, for that of the
footsteps of persons coming to the house. I have several times to-
night thought that I heard the sound of footsteps. I am sure,
however, that it was but the wind. Friends would not be likely to
come out at such an hour, or such a night; and thieves are too lazy
and self-indulgent to expose themselves to this biting frost; but
should there be any one about, our brave old Monte, who is on the
look-out, will not be slow in sounding the alarm.”
Saying this they quietly left the window, whither they had gone to
learn the cause of the menacing growl, and re-seated themselves by
the fire, as if reluctant to leave the slowly expiring embers, although
the hour was late. A few minutes only intervened after resuming
their seats, when again their sober meditations were disturbed.
Their faithful dog now growled and barked furiously, as if assailed by
an advancing foe. Simultaneously the good couple arose, and stood
in mute expectation. The contest without seemed fierce and violent.
It was, however, soon over,—the barking ceased, for, with true
canine instinct, Monte quickly discovered that a friend, not an enemy
of the family, was coming to the house, and instead of rushing to
repel the supposed intruder, he was now at the door, whimpering
and dancing for the admission of himself and his newly made friend.
Mr. Listwell knew by this movement that all was well; he advanced
and opened the door, and saw by the light that streamed out into
the darkness, a tall man advancing slowly towards the house, with a
stick in one hand, and a small bundle in the other. “It is a traveller,”
thought he, “who has missed his way, and is coming to inquire the
road. I am glad we did not go to bed earlier,—I have felt all the
evening as if somebody would be here to-night.”
The man had now halted a short distance from the door, and looked
prepared alike for flight or battle. “Come in, sir, don’t be alarmed,
you have probably lost your way.”
Slightly hesitating, the traveller walked in; not, however, without
regarding his host with a scrutinizing glance. “No, sir,” said he, “I
have come to ask you a greater favor.”
Instantly Mr. Listwell exclaimed, (as the recollection of the Virginia
forest scene flashed upon him,) “Oh, sir, I know not your name, but
I have seen your face, and heard your voice before. I am glad to see
you. I know all. You are flying for your liberty,—be seated,—be
seated,—banish all fear. You are safe under my roof.”
This recognition, so unexpected, rather disconcerted and disquieted
the noble fugitive. The timidity and suspicion of persons escaping
from slavery are easily awakened, and often what is intended to
dispel the one, and to allay the other, has precisely the opposite
effect. It was so in this case. Quickly observing the unhappy
impression made by his words and action, Mr. Listwell assumed a
more quiet and inquiring aspect, and finally succeeded in removing
the apprehensions which his very natural and generous salutation
had aroused.
Thus assured, the stranger said, “Sir, you have rightly guessed, I am,
indeed, a fugitive from slavery. My name is Madison,—Madison
Washington my mother used to call me. I am on my way to Canada,
where I learn that persons of my color are protected in all the rights
of men; and my object in calling upon you was, to beg the privilege
of resting my weary limbs for the night in your barn. It was my
purpose to have continued my journey till morning; but the piercing
cold, and the frowning darkness compelled me to seek shelter; and,
seeing a light through the lattice of your window, I was encouraged
to come here to beg the privilege named. You will do me a great
favor by affording me shelter for the night.”
“A resting-place, indeed, sir, you shall have; not, however, in my
barn, but in the best room of my house. Consider yourself, if you
please, under the roof of a friend; for such I am to you, and to all
your deeply injured race.”
While this introductory conversation was going on, the kind lady had
revived the fire, and was diligently preparing supper; for she, not
less than her husband, felt for the sorrows of the oppressed and
hunted ones of earth, and was always glad of an opportunity to do
them a service. A bountiful repast was quickly prepared, and the
hungry and toil-worn bondman was cordially invited to partake
thereof. Gratefully he acknowledged the favor of his benevolent
benefactress; but appeared scarcely to understand what such
hospitality could mean. It was the first time in his life that he had
met so humane and friendly a greeting at the hands of persons
whose color was unlike his own; yet it was impossible for him to
doubt the charitableness of his new friends, or the genuineness of
the welcome so freely given; and he therefore, with many thanks,
took his seat at the table with Mr. and Mrs. Listwell, who, desirous to
make him feel at home, took a cup of tea themselves, while urging
upon Madison the best that the house could afford.
Supper over, all doubts and apprehensions banished, the three drew
around the blazing fire, and a conversation commenced which lasted
till long after midnight.
“Now,” said Madison to Mr. Listwell, “I was a little surprised and
alarmed when I came in, by what you said; do tell me, sir, why you
thought you had seen my face before, and by what you knew me to
be a fugitive from slavery; for I am sure that I never was before in
this neighborhood, and I certainly sought to conceal what I
supposed to be the manner of a fugitive slave.”
Mr. Listwell at once frankly disclosed the secret; describing the place
where he first saw him; rehearsing the language which he (Madison)
had used; referring to the effect which his manner and speech had
made upon him; declaring the resolution he there formed to be an
abolitionist; telling how often he had spoken of the circumstance,
and the deep concern he had ever since felt to know what had
become of him; and whether he had carried out the purpose to
make his escape, as in the woods he declared he would do.
“Ever since that morning,” said Mr. Listwell, “you have seldom been
absent from my mind, and though now I did not dare to hope that I
should ever see you again, I have often wished that such might be
my fortune; for, from that hour, your face seemed to be
daguerreotyped on my memory.”
Madison looked quite astonished, and felt amazed at the narration to
which he had listened. After recovering himself he said, “I well
remember that morning, and the bitter anguish that wrung my
heart; I will state the occasion of it. I had, on the previous Saturday,
suffered a cruel lashing; had been tied up to the limb of a tree, with
my feet chained together, and a heavy iron bar placed between my
ankles. Thus suspended, I received on my naked back forty stripes,
and was kept in this distressing position three or four hours, and
was then let down, only to have my torture increased; for my
bleeding back, gashed by the cow-skin, was washed by the overseer
with old brine, partly to augment my suffering, and partly, as he
said, to prevent inflammation. My crime was that I had stayed longer
at the mill, the day previous, than it was thought I ought to have
done, which, I assured my master and the overseer, was no fault of
mine; but no excuses were allowed. ‘Hold your tongue, you
impudent rascal,’ met my every explanation. Slave-holders are so
imperious when their passions are excited, as to construe every
word of the slave into insolence. I could do nothing but submit to
the agonizing infliction. Smarting still from the wounds, as well as
from the consciousness of being whipt for no cause, I took
advantage of the absence of my master, who had gone to church, to
spend the time in the woods, and brood over my wretched lot. Oh,
sir, I remember it well,—and can never forget it.”
“But this was five years ago; where have you been since?”
“I will try to tell you,” said Madison. “Just four weeks after that
Sabbath morning, I gathered up the few rags of clothing I had, and
started, as I supposed, for the North and for freedom. I must not
stop to describe my feelings on taking this step. It seemed like
taking a leap into the dark. The thought of leaving my poor wife and
two little children caused me indescribable anguish; but consoling
myself with the reflection that once free, I could, possibly, devise
ways and means to gain their freedom also, I nerved myself up to
make the attempt. I started, but ill-luck attended me; for after being
out a whole week, strange to say, I still found myself on my master’s
grounds; the third night after being out, a season of clouds and rain
set in, wholly preventing me from seeing the North Star, which I had
trusted as my guide, not dreaming that clouds might intervene
between us.
“This circumstance was fatal to my project, for in losing my star, I
lost my way; so when I supposed I was far towards the North, and
had almost gained my freedom, I discovered myself at the very point
from which I had started. It was a severe trial, for I arrived at home
in great destitution; my feet were sore, and in travelling in the dark,
I had dashed my foot against a stump, and started a nail, and lamed
myself. I was wet and cold; one week had exhausted all my stores;
and when I landed on my master’s plantation, with all my work to do
over again,—hungry, tired, lame, and bewildered,—I almost cursed
the day that I was born. In this extremity I approached the quarters.
I did so stealthily, although in my desperation I hardly cared whether
I was discovered or not. Peeping through the rents of the quarters, I
saw my fellow-slaves seated by a warm fire, merrily passing away
the time, as though their hearts knew no sorrow. Although I envied
their seeming contentment, all wretched as I was, I despised the
cowardly acquiescence in their own degradation which it implied,
and felt a kind of pride and glory in my own desperate lot. I dared
not enter the quarters,—for where there is seeming contentment
with slavery, there is certain treachery to freedom. I proceeded
towards the great house, in the hope of catching a glimpse of my
poor wife, whom I knew might be trusted with my secrets even on
the scaffold. Just as I reached the fence which divided the field from
the garden, I saw a woman in the yard, who in the darkness I took
to be my wife; but a nearer approach told me it was not she. I was
about to speak; had I done so, I would not have been here this
night; for an alarm would have been sounded, and the hunters been
put on my track. Here were hunger, cold, thirst, disappointment, and
chagrin, confronted only by the dim hope of liberty. I tremble to
think of that dreadful hour. To face the deadly cannon’s mouth in
warm blood unterrified, is, I think, a small achievement, compared
with a conflict like this with gaunt starvation. The gnawings of
hunger conquers by degrees, till all that a man has he would give in
exchange for a single crust of bread. Thank God, I was not quite
reduced to this extremity.
“Happily for me, before the fatal moment of utter despair, my good
wife made her appearance in the yard. It was she; I knew her step.
All was well now. I was, however, afraid to speak, lest I should
frighten her. Yet speak I did; and, to my great joy, my voice was
known. Our meeting can be more easily imagined than described.
For a time hunger, thirst, weariness, and lameness were forgotten.
But it was soon necessary for her to return to the house. She being
a house-servant, her absence from the kitchen, if discovered, might
have excited suspicion. Our parting was like tearing the flesh from
my bones; yet it was the part of wisdom for her to go. She left me
with the purpose of meeting me at midnight in the very forest where
you last saw me. She knew the place well, as one of my melancholy
resorts, and could easily find it, though the night was dark.
“I hastened away, therefore, and concealed myself, to await the
arrival of my good angel. As I lay there among the leaves, I was
strongly tempted to return again to the house of my master and give
myself up; but remembering my solemn pledge on that memorable
Sunday morning, I was able to linger out the two long hours
between ten and midnight. I may well call them long hours. I have
endured much hardship; I have encountered many perils; but the
anxiety of those two hours, was the bitterest I ever experienced.
True to her word, my wife came laden with provisions, and we sat
down on the side of a log, at that dark and lonesome hour of the
night. I cannot say we talked; our feelings were too great for that;
yet we came to an understanding that I should make the woods my
home, for if I gave myself up, I should be whipped and sold away;
and if I started for the North, I should leave a wife doubly dear to
me. We mutually determined, therefore, that I should remain in the
vicinity. In the dismal swamps I lived, sir, five long years,—a cave for
my home during the day. I wandered about at night with the wolf
and the bear,—sustained by the promise that my good Susan would
meet me in the pine woods at least once a week. This promise was
redeemed, I assure you, to the letter, greatly to my relief. I had
partly become contented with my mode of life, and had made up my
mind to spend my days there; but the wilderness that sheltered me
thus long took fire, and refused longer to be my hiding-place.
“I will not harrow up your feelings by portraying the terrific scene of
this awful conflagration. There is nothing to which I can liken it. It
was horribly and indescribably grand. The whole world seemed on
fire, and it appeared to me that the day of judgment had come; that
the burning bowels of the earth had burst forth, and that the end of
all things was at hand. Bears and wolves, scorched from their
mysterious hiding-places in the earth, and all the wild inhabitants of
the untrodden forest, filled with a common dismay, ran forth, yelling,
howling, bewildered amidst the smoke and flame. The very heavens
seemed to rain down fire through the towering trees; it was by the
merest chance that I escaped the devouring element. Running
before it, and stopping occasionally to take breath, I looked back to
behold its frightful ravages, and to drink in its savage magnificence.
It was awful, thrilling, solemn, beyond compare. When aided by the
fitful wind, the merciless tempest of fire swept on, sparkling,
creaking, cracking, curling, roaring, out-doing in its dreadful splendor
a thousand thunderstorms at once. From tree to tree it leaped,
swallowing them up in its lurid, baleful glare; and leaving them
leafless, limbless, charred, and lifeless behind. The scene was
overwhelming, stunning,—nothing was spared,—cattle, tame and
wild, herds of swine and of deer, wild beasts of every name and
kind,—huge night-birds, bats, and owls, that had retired to their
homes in lofty tree-tops to rest, perished in that fiery storm. The
long-winged buzzard and croaking raven mingled their dismal cries
with those of the countless myriads of small birds that rose up to the
skies, and were lost to the sight in clouds of smoke and flame. Oh, I
shudder when I think of it! Many a poor wandering fugitive, who,
like myself, had sought among wild beasts the mercy denied by our
fellow men, saw, in helpless consternation, his dwelling-place and
city of refuge reduced to ashes forever. It was this grand
conflagration that drove me hither; I ran alike from fire and from
slavery.”
After a slight pause, (for both speaker and hearers were deeply
moved by the above recital,) Mr. Listwell, addressing Madison, said,
“If it does not weary you too much, do tell us something of your
journeyings since this disastrous burning,—we are deeply interested
in everything which can throw light on the hardships of persons
escaping from slavery; we could hear you talk all night; are there no
incidents that you could relate of your travels hither? or are they
such that you do not like to mention them.”
“For the most part, sir, my course has been uninterrupted; and,
considering the circumstances, at times even pleasant. I have
suffered little for want of food; but I need not tell you how I got it.
Your moral code may differ from mine, as your customs and usages
are different. The fact is, sir, during my flight, I felt myself robbed by
society of all my just rights; that I was in an enemy’s land, who
sought both my life and my liberty. They had transformed me into a
brute; made merchandise of my body, and, for all the purposes of
my flight, turned day into night,—and guided by my own necessities,
and in contempt of their conventionalities, I did not scruple to take
bread where I could get it.”
“And just there you were right,” said Mr. Listwell; “I once had doubts
on this point myself, but a conversation with Gerrit Smith, (a man,
by the way, that I wish you could see, for he is a devoted friend of
your race, and I know he would receive you gladly,) put an end to all
my doubts on this point. But do not let me interrupt you.”
“I had but one narrow escape during my whole journey,” said
Madison.
“Do let us hear of it,” said Mr. Listwell.
“Two weeks ago,” continued Madison, “after travelling all night, I
was overtaken by daybreak, in what seemed to me an almost
interminable wood. I deemed it unsafe to go farther, and, as usual, I
looked around for a suitable tree in which to spend the day. I liked
one with a bushy top, and found one just to my mind. Up I climbed,
and hiding myself as well as I could, I, with this strap, (pulling one
out of his old coat-pocket,) lashed myself to a bough, and flattered
myself that I should get a good night’s sleep that day; but in this I
was soon disappointed. I had scarcely got fastened to my natural
hammock, when I heard the voices of a number of persons,
apparently approaching the part of the woods where I was. Upon my
word, sir, I dreaded more these human voices than I should have
done those of wild beasts. I was at a loss to know what to do. If I
descended, I should probably be discovered by the men; and if they
had dogs I should, doubtless, be ‘treed.’ It was an anxious moment,
but hardships and dangers have been the accompaniments of my
life; and have, perhaps, imparted to me a certain hardness of
character, which, to some extent, adapts me to them. In my present
predicament, I decided to hold my place in the tree-top, and abide
the consequences. But here I must disappoint you; for the men, who
were all colored, halted at least a hundred yards from me, and
began with their axes, in right good earnest, to attack the trees. The
sound of their laughing axes was like the report of as many well-
charged pistols. By and by there came down at least a dozen trees
with a terrible crash. They leaped upon the fallen trees with an air of
victory. I could see no dog with them, and felt myself comparatively
safe, though I could not forget the possibility that some freak or
fancy might bring the axe a little nearer my dwelling than comported
with my safety.
“There was no sleep for me that day, and I wished for night. You
may imagine that the thought of having the tree attacked under me
was far from agreeable, and that it very easily kept me on the look-
out. The day was not without diversion. The men at work seemed to
be a gay set; and they would often make the woods resound with
that uncontrolled laughter for which we, as a race, are remarkable. I
held my place in the tree till sunset,—saw the men put on their
jackets to be off. I observed that all left the ground except one,
whom I saw sitting on the side of a stump, with his head bowed,
and his eyes apparently fixed on the ground. I became interested in
him. After sitting in the position to which I have alluded ten or
fifteen minutes, he left the stump, walked directly towards the tree
in which I was secreted, and halted almost under the same. He
stood for a moment and looked around, deliberately and reverently
took off his hat, by which I saw that he was a man in the evening of
life, slightly bald and quite gray. After laying down his hat carefully,
he knelt and prayed aloud, and such a prayer, the most fervent,
earnest, and solemn, to which I think I ever listened. After
reverently addressing the Almighty, as the all-wise, all-good, and the
common Father of all mankind, he besought God for grace, for
strength, to bear up under, and to endure, as a good soldier, all the
hardships and trials which beset the journey of life, and to enable
him to live in a manner which accorded with the gospel of Christ. His
soul now broke out in humble supplication for deliverance from
bondage. ‘O thou,’ said he, ‘that hearest the raven’s cry, take pity on
poor me! O deliver me! O deliver me! in mercy, O God, deliver me
from the chains and manifold hardships of slavery! With thee, O
Father, all things are possible. Thou canst stand and measure the
earth. Thou hast beheld and drove asunder the nations,—all power
is in thy hand,—thou didst say of old, “I have seen the affliction of
my people, and am come to deliver them,”—Oh look down upon our
afflictions, and have mercy upon us.’ But I cannot repeat his prayer,
nor can I give you an idea of its deep pathos. I had given but little
attention to religion, and had but little faith in it; yet, as the old man
prayed, I felt almost like coming down and kneel by his side, and
mingle my broken complaint with his.
“He had already gained my confidence; as how could it be
otherwise? I knew enough of religion to know that the man who
prays in secret is far more likely to be sincere than he who loves to
pray standing in the street, or in the great congregation. When he
arose from his knees, like another Zacheus, I came down from the
tree. He seemed a little alarmed at first, but I told him my story, and
the good man embraced me in his arms, and assured me of his
sympathy.
“I was now about out of provisions, and thought I might safely ask
him to help me replenish my store. He said he had no money; but if
he had, he would freely give it me. I told him I had one dollar; it
was all the money I had in the world. I gave it to him, and asked
him to purchase some crackers and cheese, and to kindly bring me
the balance; that I would remain in or near that place, and would
come to him on his return, if he would whistle. He was gone only
about an hour. Meanwhile, from some cause or other, I know not
what, (but as you shall see very wisely,) I changed my place. On his
return I started to meet him; but it seemed as if the shadow of
approaching danger fell upon my spirit, and checked my progress. In
a very few minutes, closely on the heels of the old man, I distinctly
saw fourteen men, with something like guns in their hands.”
“Oh! the old wretch!” exclaimed Mrs. Listwell, “he had betrayed you,
had he?”
“I think not,” said Madison, “I cannot believe that the old man was
to blame. He probably went into a store, asked for the articles for
which I sent, and presented the bill I gave him; and it is so unusual
for slaves in the country to have money, that fact, doubtless, excited
suspicion, and gave rise to inquiry. I can easily believe that the
truthfulness of the old man’s character compelled him to disclose the
facts; and thus were these blood-thirsty men put on my track. Of
course I did not present myself; but hugged my hiding-place
securely. If discovered and attacked, I resolved to sell my life as
dearly as possible.
“After searching about the woods silently for a time, the whole
company gathered around the old man; one charged him with lying,
and called him an old villain; said he was a thief; charged him with
stealing money; said if he did not instantly tell where he got it, they
would take the shirt from his old back, and give him thirty-nine
lashes.
“‘I did not steal the money,’ said the old man, ‘it was given me, as I
told you at the store; and if the man who gave it me is not here, it is
not my fault.’
“‘Hush! you lying old rascal; we’ll make you smart for it. You shall
not leave this spot until you have told where you got that money.’
“They now took hold of him, and began to strip him; while others
went to get sticks with which to beat him. I felt, at the moment, like
rushing out in the midst of them; but considering that the old man
would be whipped the more for having aided a fugitive slave, and
that, perhaps, in the melée he might be killed outright, I disobeyed
this impulse. They tied him to a tree, and began to whip him. My
own flesh crept at every blow, and I seem to hear the old man’s
piteous cries even now. They laid thirty-nine lashes on his bare back,
and were going to repeat that number, when one of the company
besought his comrades to desist. ‘You’ll kill the d—d old scoundrel!
You’ve already whipt a dollar’s worth out of him, even if he stole it!’
‘O yes,’ said another, ‘let him down. He’ll never tell us another lie, I’ll
warrant ye!’ With this, one of the company untied the old man, and
bid him go about his business.
The old man left, but the company remained as much as an hour,
scouring the woods. Round and round they went, turning up the
underbrush, and peering about like so many bloodhounds. Two or
three times they came within six feet of where I lay. I tell you I held
my stick with a firmer grasp than I did in coming up to your house
to-night. I expected to level one of them at least. Fortunately,
however, I eluded their pursuit, and they left me alone in the woods.
“My last dollar was now gone, and you may well suppose I felt the
loss of it; but the thought of being once again free to pursue my
journey, prevented that depression which a sense of destitution
causes; so swinging my little bundle on my back, I caught a glimpse
of the Great Bear (which ever points the way to my beloved star,)
and I started again on my journey. What I lost in money I made up
at a hen-roost that same night, upon which I fortunately came.”
“But you didn’t eat your food raw? How did you cook it?” said Mrs.
Listwell.
“O no, Madam,” said Madison, turning to his little bundle;—“I had
the means of cooking.” Here he took out of his bundle an old-
fashioned tinder-box, and taking up a piece of a file, which he
brought with him, he struck it with a heavy flint, and brought out at
least a dozen sparks at once. “I have had this old box,” said he,
“more than five years. It is the only property saved from the fire in
the dismal swamp. It has done me good service. It has given me the
means of broiling many a chicken!”
It seemed quite a relief to Mrs. Listwell to know that Madison had, at
least, lived upon cooked food. Women have a perfect horror of
eating uncooked food.
By this time thoughts of what was best to be done about getting
Madison to Canada, began to trouble Mr. Listwell; for the laws of
Ohio were very stringent against any one who should aid, or who
were found aiding a slave to escape through that State. A citizen, for
the simple act of taking a fugitive slave in his carriage, had just been
stripped of all his property, and thrown penniless upon the world.
Notwithstanding this, Mr. Listwell was determined to see Madison
safely on his way to Canada. “Give yourself no uneasiness,” said he
to Madison, “for if it cost my farm, I shall see you safely out of the
States, and on your way to a land of liberty. Thank God that there is
such a land so near us! You will spend to-morrow with us, and to-
morrow night I will take you in my carriage to the Lake. Once upon
that, and you are safe.”
“Thank you! thank you,” said the fugitive; “I will commit myself to
your care.”
For the first time during five years, Madison enjoyed the luxury of
resting his limbs on a comfortable bed, and inside a human
habitation. Looking at the white sheets, he said to Mr. Listwell,
“What, sir! you don’t mean that I shall sleep in that bed?”
“Oh yes, oh yes.”
After Mr. Listwell left the room, Madison said he really hesitated
whether or not he should lie on the floor; for that was far more
comfortable and inviting than any bed to which he had been used.

We pass over the thoughts and feelings, the hopes and fears, the
plans and purposes, that revolved in the mind of Madison during the
day that he was secreted at the house of Mr. Listwell. The reader will
be content to know that nothing occurred to endanger his liberty, or
to excite alarm. Many were the little attentions bestowed upon him
in his quiet retreat and hiding-place. In the evening, Mr. Listwell,
after treating Madison to a new suit of winter clothes, and
replenishing his exhausted purse with five dollars, all in silver,
brought out his two-horse wagon, well provided with buffaloes, and
silently started off with him to Cleveland. They arrived there without
interruption, a few minutes before sunrise the next morning.
Fortunately the steamer Admiral lay at the wharf, and was to start
for Canada at nine o’clock. Here the last anticipated danger was
surmounted. It was feared that just at this point the hunters of men
might be on the look-out, and, possibly, pounce upon their victim.
Mr. Listwell saw the captain of the boat; cautiously sounded him on
the matter of carrying liberty-loving passengers, before he
introduced his precious charge. This done, Madison was conducted
on board. With usual generosity this true subject of the
emancipating queen welcomed Madison, and assured him that he
should be safely landed in Canada, free of charge. Madison now felt
himself no more a piece of merchandise, but a passenger, and, like
any other passenger, going about his business, carrying with him
what belonged to him, and nothing which rightfully belonged to
anybody else.
Wrapped in his new winter suit, snug and comfortable, a pocket full
of silver, safe from his pursuers, embarked for a free country,
Madison gave every sign of sincere gratitude, and bade his kind
benefactor farewell, with such a grip of the hand as bespoke a heart
full of honest manliness, and a soul that knew how to appreciate
kindness. It need scarcely be said that Mr. Listwell was deeply
moved by the gratitude and friendship he had excited in a nature so
noble as that of the fugitive. He went to his home that day with a
joy and gratification which knew no bounds. He had done something
“to deliver the spoiled out of the hands of the spoiler,” he had given
bread to the hungry, and clothes to the naked; he had befriended a
man to whom the laws of his country forbade all friendship,—and in
proportion to the odds against his righteous deed, was the delightful
satisfaction that gladdened his heart. On reaching home, he
exclaimed, “He is safe,—he is safe,—he is safe,”—and the cup of his
joy was shared by his excellent lady. The following letter was
received from Madison a few days after.

“Windsor, Canada West, Dec. 16, 1840.


My dear Friend,—for such you truly are:—
Madison is out of the woods at last; I nestle in the mane of the
British lion, protected by his mighty paw from the talons and the
beak of the American eagle. I am free, and breathe an
atmosphere too pure for slaves, slave-hunters, or slave-holders.
My heart is full. As many thanks to you, sir, and to your kind
lady, as there are pebbles on the shores of Lake Erie; and may
the blessing of God rest upon you both. You will never be
forgotten by your profoundly grateful friend,
Madison Washington.”

PART III.

——His head was with his heart,


And that was far away!

Childe Harold.
Just upon the edge of the great road from Petersburg, Virginia, to
Richmond, and only about fifteen miles from the latter place, there
stands a somewhat ancient and famous public tavern, quite
notorious in its better days, as being the grand resort for most of the
leading gamblers, horse-racers, cock-fighters, and slave-traders from
all the country round about. This old rookery, the nucleus of all sorts
of birds, mostly those of ill omen, has, like everything else peculiar
to Virginia, lost much of its ancient consequence and splendor; yet it
keeps up some appearance of gaiety and high life, and is still
frequented, even by respectable travellers, who are unacquainted
with its past history and present condition. Its fine old portico looks
well at a distance, and gives the building an air of grandeur. A nearer
view, however, does little to sustain this pretension. The house is
large, and its style imposing, but time and dissipation, unfailing in
their results, have made ineffaceable marks upon it, and it must, in
the common course of events, soon be numbered with the things
that were. The gloomy mantle of ruin is, already, outspread to
envelop it, and its remains, even but now remind one of a human
skull, after the flesh has mingled with the earth. Old hats and rags
fill the places in the upper windows once occupied by large panes of
glass, and the moulding boards along the roofing have dropped off
from their places, leaving holes and crevices in the rented wall for
bats and swallows to build their nests in. The platform of the portico,
which fronts the highway is a rickety affair, its planks are loose, and
in some places entirely gone, leaving effective man-traps in their
stead for nocturnal ramblers. The wooden pillars, which once
supported it, but which now hang as encumbrances, are all rotten,
and tremble with the touch. A part of the stable, a fine old structure
in its day, which has given comfortable shelter to hundreds of the
noblest steeds of “the Old Dominion” at once, was blown down
many years ago, and never has been, and probably never will be,
rebuilt. The doors of the barn are in wretched condition; they will
shut with a little human strength to help their worn out hinges, but
not otherwise. The side of the great building seen from the road is
much discolored in sundry places by slops poured from the upper
windows, rendering it unsightly and offensive in other respects.
Three or four great dogs, looking as dull and gloomy as the mansion
itself, lie stretched out along the door-sills under the portico; and
double the number of loafers, some of them completely rum-ripe,
and others ripening, dispose themselves like so many sentinels
about the front of the house. These latter understand the science of
scraping acquaintance to perfection. They know every-body, and
almost every-body knows them. Of course, as their title implies, they
have no regular employment. They are (to use an expressive
phrase) hangers on, or still better, they are what sailors would
denominate holders-on to the slack, in every-body’s mess, and in
nobody’s watch. They are, however, as good as the newspaper for
the events of the day, and they sell their knowledge almost as
cheap. Money they seldom have; yet they always have capital the
most reliable. They make their way with a succeeding traveller by
intelligence gained from a preceding one. All the great names of
Virginia they know by heart, and have seen their owners often. The
history of the house is folded in their lips, and they rattle off stories
in connection with it, equal to the guides at Dryburgh Abbey. He
must be a shrewd man, and well skilled in the art of evasion, who
gets out of the hands of these fellows without being at the expense
of a treat.
It was at this old tavern, while on a second visit to the State of
Virginia in 1841, that Mr. Listwell, unacquainted with the fame of the
place, turned aside, about sunset, to pass the night. Riding up to the
house, he had scarcely dismounted, when one of the half dozen bar-
room fraternity met and addressed him in a manner exceedingly
bland and accommodating.
“Fine evening, sir.”
“Very fine,” said Mr. Listwell. “This is a tavern, I believe?”
“O yes, sir, yes; although you may think it looks a little the worse for
wear, it was once as good a house as any in Virginy. I make no
doubt if ye spend the night here, you’ll think it a good house yet; for
there aint a more accommodating man in the country than you’ll find
the landlord.”
Listwell. “The most I want is a good bed for myself, and a full
manger for my horse. If I get these, I shall be quite satisfied.”
Loafer. “Well, I alloys like to hear a gentleman talk for his horse; and
just becase the horse can’t talk for itself. A man that don’t care
about his beast, and don’t look arter it when he’s travelling, aint
much in my eye anyhow. Now, sir, I likes a horse, and I’ll guarantee
your horse will be taken good care on here. That old stable, for all
you see it looks so shabby now, once sheltered the great Eclipse,
when he run here agin Batchelor and Jumping Jemmy. Them was
fast horses, but he beat ’em both.”
Listwell. “Indeed.”
Loafer. “Well, I rather reckon you’ve travelled a right smart distance
to-day, from the look of your horse?”
Listwell. “Forty miles only.”
Loafer. “Well! I’ll be darned if that aint a pretty good only. Mister,
that beast of yours is a singed cat, I warrant you. I never see’d a
creature like that that wasn’t good on the road. You’ve come about
forty miles, then?”
Listwell. “Yes, yes, and a pretty good pace at that.”
Loafer. “You’re somewhat in a hurry, then, I make no doubt? I
reckon I could guess if I would, what you’re going to Richmond for?
It wouldn’t be much of a guess either; for it’s rumored hereabouts,
that there’s to be the greatest sale of niggers at Richmond to-
morrow that has taken place there in a long time; and I’ll be bound
you’re a going there to have a hand in it.”
Listwell. “Why, you must think, then, that there’s money to be made
at that business?”
Loafer. “Well, ’pon my honor, sir, I never made any that way myself;
but it stands to reason that it’s a money making business; for almost
all other business in Virginia is dropped to engage in this. One thing
is sartain, I never see’d a nigger-buyer yet that hadn’t a plenty of
money, and he wasn’t as free with it as water. I has known one on
’em to treat as high as twenty times in a night; and, ginerally
speaking, they’s men of edication, and knows all about the
government. The fact is, sir, I alloys like to hear ’em talk, bekase I
alloys can learn something from them.”
Listwell. “What may I call your name, sir?”
Loafer. “Well, now, they calls me Wilkes. I’m known all around by the
gentlemen that comes here. They all knows old Wilkes.”
Listwell. “Well, Wilkes, you seem to be acquainted here, and I see
you have a strong liking for a horse. Be so good as to speak a kind
word for mine to the hostler to-night, and you’ll not lose anything by
it.”
Loafer. “Well, sir, I see you don’t say much, but you’ve got an insight
into things. It’s alloys wise to get the good will of them that’s
acquainted about a tavern; for a man don’t know when he goes into
a house what may happen, or how much he may need a friend.”
Here the loafer gave Mr. Listwell a significant grin, which expressed a
sort of triumphant pleasure at having, as he supposed, by his tact
succeeded in placing so fine appearing a gentleman under
obligations to him.
The pleasure, however, was mutual; for there was something so
insinuating in the glance of this loquacious customer, that Mr.
Listwell was very glad to get quit of him, and to do so more
successfully, he ordered his supper to be brought to him in his
private room, private to the eye, but not to the ear. This room was
directly over the bar, and the plastering being off, nothing but pine
boards and naked laths separated him from the disagreeable
company below,—he could easily hear what was said in the bar-
room, and was rather glad of the advantage it afforded, for, as you
shall see, it furnished him important hints as to the manner and
deportment he should assume during his stay at that tavern.
Mr. Listwell says he had got into his room but a few moments, when
he heard the officious Wilkes below, in a tone of disappointment,
exclaim, “Whar’s that gentleman?” Wilkes was evidently expecting to
meet with his friend at the bar-room, on his return, and had no
doubt of his doing the handsome thing. “He has gone to his room,”
answered the landlord, “and has ordered his supper to be brought to
him.”
Here some one shouted out, “Who is he, Wilkes? Where’s he going?”
“Well, now, I’ll be hanged if I know; but I’m willing to make any man
a bet of this old hat agin a five dollar bill, that that gent is as full of
money as a dog is of fleas. He’s going down to Richmond to buy
niggers, I make no doubt. He’s no fool, I warrant ye.”
“Well, he acts d—d strange,” said another, “anyhow. I likes to see a
man, when he comes up to a tavern, to come straight into the bar-
room, and show that he’s a man among men. Nobody was going to
bite him.”
“Now, I don’t blame him a bit for not coming in here. That man
knows his business, and means to take care on his money,”
answered Wilkes.
“Wilkes, you’re a fool. You only say that, becase you hope to get a
few coppers out on him.”
“You only measure my corn by your half-bushel, I won’t say that
you’re only mad becase I got the chance of speaking to him first.”
“O Wilkes! you’re known here. You’ll praise up any body that will
give you a copper; besides, ’tis my opinion that that fellow who took
his long slab-sides up stairs, for all the world just like a half-scared
woman, afraid to look honest men in the face, is a Northerner, and
as mean as dishwater.”
“Now what will you bet of that,” said Wilkes.
The speaker said, “I make no bets with you, ’kase you can get that
fellow up stairs there to say anything.”
“Well,” said Wilkes, “I am willing to bet any man in the company that
that gentleman is a nigger-buyer. He didn’t tell me so right down,
but I reckon I knows enough about men to give a pretty clean guess
as to what they are arter.”
The dispute as to who Mr. Listwell was, what his business, where he
was going, etc., was kept up with much animation for some time,
and more than once threatened a serious disturbance of the peace.
Wilkes had his friends as well as his opponents. After this sharp
debate, the company amused themselves by drinking whiskey, and
telling stories. The latter consisting of quarrels, fights, rencontres,
and duels, in which distinguished persons of that neighborhood, and
frequenters of that house, had been actors. Some of these stories
were frightful enough, and were told, too, with a relish which
bespoke the pleasure of the parties with the horrid scenes they
portrayed. It would not be proper here to give the reader any idea of
the vulgarity and dark profanity which rolled, as “a sweet morsel,”
under these corrupt tongues. A more brutal set of creatures,
perhaps, never congregated.
Disgusted, and a little alarmed withal, Mr. Listwell, who was not
accustomed to such entertainment, at length retired, but not to
sleep. He was too much wrought upon by what he had heard to rest
quietly, and what snatches of sleep he got, were interrupted by
dreams which were anything than pleasant. At eleven o’clock, there
seemed to be several hundreds of persons crowding into the house.
A loud and confused clamour, cursing and cracking of whips, and the
noise of chains startled him from his bed; for a moment he would
have given the half of his farm in Ohio to have been at home. This
uproar was kept up with undulating course, till near morning. There
was loud laughing,—loud singing,—loud cursing,—and yet there
seemed to be weeping and mourning in the midst of all. Mr. Listwell
said he had heard enough during the forepart of the night to
convince him that a buyer of men and women stood the best chance
of being respected. And he, therefore, thought it best to say nothing
which might undo the favorable opinion that had been formed of
him in the bar-room by at least one of the fraternity that swarmed
about it. While he would not avow himself a purchaser of slaves, he
deemed it not prudent to disavow it. He felt that he might, properly,

You might also like