Learning Network Programming With Java 1st Edition Richard M Reese - Download The Ebook With All Fully Detailed Chapters
Learning Network Programming With Java 1st Edition Richard M Reese - Download The Ebook With All Fully Detailed Chapters
com
https://ebookmeta.com/product/learning-network-programming-
with-java-1st-edition-richard-m-reese/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookmeta.com/product/learning-network-programming-with-
java-1st-edition-richard-m-reese-2/
ebookmeta.com
https://ebookmeta.com/product/neural-network-programming-with-java-
second-edition-fabio-m-soares/
ebookmeta.com
https://ebookmeta.com/product/learning-reactive-programming-with-
java-8-1st-edition-nickolay-tsvetinov/
ebookmeta.com
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
https://ebookmeta.com/product/economics-of-regulation-and-
antitrust-5th-edition-viscusi-w-kip-harrington-jr-joseph-e-sappington-
david-e-m/
ebookmeta.com
https://ebookmeta.com/product/beginning-power-bi-2nd-edition-dan-
clark/
ebookmeta.com
https://ebookmeta.com/product/dr-bad-boy-1st-edition-ainsley-booth-
sadie-haller/
ebookmeta.com
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
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.
Livery Place
35 Livery Street
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
Technical Editor
Humera Shaikh
Copy Editor
Priyanka Ravi
Project Coordinator
Shipra Chawhan
Proofreader
Safis Editing
Indexer
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.
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.
https://www2.packtpub.com/books/subscription/packtlib
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.
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.
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.
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.
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.
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.
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.
System.out.println("CanonicalHostName: "
+ address.getCanonicalHostName());
System.out.println("HostAddress: " +
address.getHostAddress());
System.out.println("HostName: " +
address.getHostName());
HostAddress: 83.166.169.231
HostName: www.packtpub.com
address.isReachable(10000);
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 several buffer classes that support primitive data types,
such as character, integer, and float.
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:
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
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.
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.
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.
PART III.
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,