Java Network Programming Fourth Edition Elliotte Rusty Harold download
Java Network Programming Fourth Edition Elliotte Rusty Harold download
https://ebookname.com/product/java-network-programming-fourth-
edition-elliotte-rusty-harold/
https://ebookname.com/product/xml-in-a-nutshell-3rd-ed-edition-
elliotte-rusty-harold/
https://ebookname.com/product/linear-programming-and-network-
flows-fourth-edition-m-s-bazaraa/
https://ebookname.com/product/java-programming-5th-edition-joyce-
farrell/
https://ebookname.com/product/scott-2007-standard-postage-stamp-
catalogue-vol-6-countries-of-the-world-so-z-163rd-edition-james-
e-kloetzel/
601 great scrapbook ideas 1st ed Edition Memory Makers
Books
https://ebookname.com/product/601-great-scrapbook-ideas-1st-ed-
edition-memory-makers-books/
https://ebookname.com/product/on-percs-facebooking-while-
intoxicated-1st-edition-mike-rainey/
https://ebookname.com/product/if-not-now-when-writings-in-
defense-of-europe-1st-edition-mathijs-koenraadt/
https://ebookname.com/product/research-for-development-a-
practical-guide-1st-edition-sophie-laws/
https://ebookname.com/product/a-slice-of-organic-life-1st-
edition-sheherazade-goldsmith/
Handbook of Diabetes 4th Edition Rudy Bilous
https://ebookname.com/product/handbook-of-diabetes-4th-edition-
rudy-bilous/
FOURTH EDITION
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. Java Network Programming, the image of a North American river otter, and related trade dress
are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐
mark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-35767-2
[LSI]
This book is dedicated to my dog, Thor.
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
2. Streams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Output Streams 26
Input Streams 31
Marking and Resetting 34
Filter Streams 35
Chaining Filters Together 37
Buffered Streams 38
v
PrintStream 39
Data Streams 41
Readers and Writers 44
Writers 45
OutputStreamWriter 47
Readers 47
Filter Readers and Writers 49
PrintWriter 51
3. Threads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Running Threads 55
Subclassing Thread 56
Implementing the Runnable Interface 58
Returning Information from a Thread 60
Race Conditions 61
Polling 63
Callbacks 63
Futures, Callables, and Executors 68
Synchronization 70
Synchronized Blocks 72
Synchronized Methods 74
Alternatives to Synchronization 75
Deadlock 77
Thread Scheduling 78
Priorities 78
Preemption 79
Thread Pools and Executors 89
4. Internet Addresses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
The InetAddress Class 95
Creating New InetAddress Objects 95
Getter Methods 100
Address Types 102
Testing Reachability 106
Object Methods 106
Inet4Address and Inet6Address 107
The NetworkInterface Class 108
Factory Methods 108
Getter Methods 110
Some Useful Programs 111
SpamCheck 111
vi | Table of Contents
Processing Web Server Logfiles 112
6. HTTP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
The Protocol 169
Keep-Alive 175
HTTP Methods 177
The Request Body 179
Cookies 181
CookieManager 184
CookieStore 185
7. URLConnections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Opening URLConnections 188
Table of Contents | ix
Configuring SSLServerSockets 343
Choosing the Cipher Suites 343
Session Management 344
Client Mode 344
x | Table of Contents
SO_TIMEOUT 417
SO_RCVBUF 418
SO_SNDBUF 419
SO_REUSEADDR 419
SO_BROADCAST 419
IP_TOS 420
Some Useful Applications 421
Simple UDP Clients 421
UDPServer 425
A UDP Echo Client 428
DatagramChannel 431
Using DatagramChannel 431
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Table of Contents | xi
Preface
Java’s growth over the past 20 years has been nothing short of phenomenal. Given Java’s
rapid rise to prominence and the even more spectacular growth of the Internet, it’s a
little surprising that network programming in Java remains so mysterious to so many.
It doesn’t have to be. In fact, writing network programs in Java is quite simple, as this
book will show. Readers with previous experience in network programming in a Unix,
Windows, or Macintosh environment will be pleasantly surprised at how much easier
it is to write equivalent programs in Java. The Java core API includes well-designed
interfaces to most network features. Indeed, there is very little application layer network
software you can write in C or C++ that you can’t write more easily in Java. Java Network
Programming, Fourth Edition, endeavors to show you how to take advantage of Java’s
network class library to quickly and easily write programs that accomplish many com‐
mon networking tasks. Some of these include:
Java is the first (though no longer the only) language to provide such a powerful cross-
platform network library for handling all these diverse tasks. Java Network Program‐
ming exposes the power and sophistication of this library. This book’s goal is to enable
xiii
you to start using Java as a platform for serious network programming. To do so, this
book provides a general background in network fundamentals, as well as detailed dis‐
cussions of Java’s facilities for writing network programs. You’ll learn how to write Java
programs that share data across the Internet for games, collaboration, software updates,
file transfer, and more. You’ll also get a behind-the-scenes look at HTTP, SMTP,
TCP/IP, and the other protocols that support the Internet and the Web. When you finish
this book, you’ll have the knowledge and the tools to create the next generation of
software that takes full advantage of the Internet.
xiv | Preface
The next two chapters throw some light on two parts of Java programming that are
critical to almost all network programs but are often misunderstood and misused: I/O
and threading. Chapter 2, Streams, explores Java’s classic I/O which—despite the new
I/O APIs—isn’t going away any time soon and is still the preferred means of handling
input and output in most client applications. Understanding how Java handles I/O in
the general case is a prerequisite for understanding the special case of how Java handles
network I/O. Chapter 3, Threads, explores multithreading and synchronization, with a
special emphasis on how they can be used for asynchronous I/O and network servers.
Experienced Java programmers may be able to skim or skip these two chapters. However,
Chapter 4, Internet Addresses, is essential reading for everyone. It shows how Java pro‐
grams interact with the Domain Name System through the InetAddress class, the one
class that’s needed by essentially all network programs. Once you’ve finished this chap‐
ter, it’s possible to jump around in the book as your interests and needs dictate.
Chapter 5, URLs and URIs, explores Java’s URL class, a powerful abstraction for down‐
loading information and files from network servers of many kinds. The URL class enables
you to connect to and download files and documents from a network server without
concerning yourself with the details of the protocol the server speaks. It lets you connect
to an FTP server using the same code you use to talk to an HTTP server or to read a file
on the local hard disk. You’ll also learn about the newer URI class, a more standards-
conformant alternative for identifying but not retrieving resources.
Chapter 6, HTTP, delves deeper into the HTTP protocol specifically. Topics covered
include REST, HTTP headers, and cookies. Chapter 7, URLConnections, shows you how
to use the URLConnection and HttpURLConnection classes not just to download data
from web servers, but to upload documents and configure connections.
Chapter 8 through Chapter 10 discuss Java’s low-level socket classes for network access.
Chapter 8, Sockets for Clients, introduces the Java sockets API and the Socket class in
particular. It shows you how to write network clients that interact with TCP servers of
all kinds including whois, dict, and HTTP. Chapter 9, Sockets for Servers, shows you
how to use the ServerSocket class to write servers for these and other protocols. Finally,
Chapter 10, Secure Sockets, shows you how to protect your client-server communica‐
tions using the Secure Sockets Layer (SSL) and the Java Secure Sockets Extension (JSSE).
Chapter 11, Nonblocking I/O, introduces the new I/O APIs specifically designed for
network servers. These APIs enable a program to figure out whether a connection is
ready before it tries to read from or write to the socket. This allows a single thread to
manage many different connections simultaneously, thereby placing much less load on
the virtual machine. The new I/O APIs don’t help much for small servers or clients that
don’t open many simultaneous connections, but they may provide performance boosts
for high-volume servers that want to transmit as much data as the network can handle
as fast as the network can deliver it.
Preface | xv
Chapter 12, UDP, introduces the User Datagram Protocol (UDP) and the associated
DatagramPacket and DatagramSocket classes that provide fast, unreliable communi‐
cation. Finally, Chapter 13, IP Multicast, shows you how to use UDP to communicate
with multiple hosts at the same time.
Java Versions
Java’s network classes have changed a lot more slowly since Java 1.0 than other parts of
the core API. In comparison to the AWT or I/O, there have been almost no changes and
only a few additions. Of course, all network programs make extensive use of the I/O
classes and some make heavy use of GUIs. This book is written with the assumption
that you are coding with at least Java 5.0. In general, I use Java 5 features like generics
and the enhanced for loop freely without further explanation.
For network programming purposes, the distinction between Java 5 and Java 6 is not
large. Most examples look identical in the two versions. When a particular method or
class is new in Java 6, 7, or 8, it is noted by a comment following its declaration like this:
public void setFixedLengthStreamingMode(long contentLength) // Java 7
Java 7 is a bit more of a stretch. I have not shied away from using features introduced
in Java 7 where they seemed especially useful or convenient—for instance, try-with-
resources and multicatch are both very helpful when trying to fit examples into the
limited space available in a printed book—but I have been careful to point out my use
of such features.
Overall, though, Java’s networking API has been relatively stable since Java 1.0. Very
little of the post-1.0 networking API has ever been deprecated, and additions have been
xvi | Preface
relatively minor. You shouldn’t have any trouble using this book after Java 8 is released.
New APIs, however, have been somewhat more frequent in the supporting classes, par‐
ticularly I/O, which has undergone three major revisions since Java 1.0.
Preface | xvii
Conventions Used in This Book
Body text is Minion Pro, normal, like you’re reading now.
A monospaced typewriter font is used for:
• Command lines and options that should be typed verbatim on the screen
Significant code fragments and complete programs are generally placed into a separate
paragraph, like this:
Socket s = new Socket("java.oreilly.com", 80);
if (!s.getTcpNoDelay()) s.setTcpNoDelay(true);
xviii | Preface
When code is presented as fragments rather than complete programs, the existence of
the appropriate import statements should be inferred. For example, in the preceding
code fragment you may assume that java.net.Socket was imported.
Some examples intermix user input with program output. In these cases, the user input
will be displayed in bold, as in this example from Chapter 9:
% telnet rama.poly.edu 7
Trying 128.238.10.212...
Connected to rama.poly.edu.
Escape character is '^]'.
This is a test
This is a test
This is another test
This is another test
9876543210
9876543210
^]
telnet> close
Connection closed.
Finally, although many of the examples used here are toy examples unlikely to be reused,
a few of the classes I develop have real value. Please feel free to reuse them or any parts
of them in your own code. No special permission is required. They are in the public
domain (although the same is most definitely not true of the explanatory text!).
Preface | xix
worked on this book, I’m sure there are mistakes and typographical errors that we missed
here somewhere. And I’m sure that at least one of them is a really embarrassing whopper
of a problem. If you find a mistake or a typo, please let me know so I can correct it. I’ll
post it on the O’Reilly website at http://oreil.ly/java_np_errata. Before reporting errors,
please check one of those pages to see if I already know about it and have posted a fix.
Any errors that are reported will be fixed in future printings.
xx | Preface
ogy, and dozens more. For more information about Safari Books Online, please visit us
online.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/java-network-prgamming.
To comment or ask technical questions about this book, send email to bookques
tions@oreilly.com.
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
Many people were involved in the production of this book. My editor, Mike Loukides,
got things rolling, and provided many helpful comments along the way that substantially
improved the book. Dr. Peter “Peppar” Parnes helped out immensely with Chapter 13.
The technical editors all provided invaluable assistance in hunting down errors and
omissions. Simon St. Laurent provided crucial advice on which topics deserved more
coverage. Scott Oaks lent his thread expertise to Chapter 3, proving once again by the
many subtle bugs he hunted down that multithreading still requires the attention of an
expert. Ron Hitchens shone light into many of the darker areas of the new I/O APIs.
Marc Loy and Jim Elliott reviewed some of the most bleeding edge material in the book.
Timothy F. Rohaly was unswerving in his commitment to making sure I closed all my
sockets and caught all possible exceptions, and in general wrote the cleanest, safest, most
exemplary code I could write. John Zukowski found numerous errors of omission, all
now filled thanks to him. And the eagle-eyed Avner Gelb displayed an astonishing ability
to spot mistakes that had somehow managed to go unnoticed by myself, all the other
Preface | xxi
editors, and the tens of thousands of readers of the first edition. Alex Stangl and Ryan
Cuprak provided further assistance with spotting both new and lingering mistakes in
this latest edition.
It isn’t customary to thank the publisher, but the publisher does set the tone for the rest
of the company, authors, editors, and production staff alike; and I think Tim O’Reilly
deserves special credit for making O’Reilly Media absolutely one of the best houses an
author can write for. If there’s one person without whom this book would never have
been written, it’s him. If you, the reader, find O’Reilly books to be consistently better
than most of the dreck on the market, the reason really can be traced straight back to
Tim.
My agent, David Rogelberg, convinced me it was possible to make a living writing books
like this rather than working in an office. The entire crew at ibiblio.org over the last
several years has really helped me to communicate better with my readers in a variety
of ways. Every reader who sent in bouquets and brickbats for previous editions has been
instrumental in helping me write this much-improved edition. All these people deserve
much thanks and credit. Finally, as always, I’d like to offer my largest thanks to my wife,
Beth, without whose love and support this book would never have happened.
—Elliotte Rusty Harold
elharo@ibiblio.org
July 5, 2013
xxii | Preface
CHAPTER 1
Basic Network Concepts
• Text editors like BBEdit save and open files directly from FTP servers.
• IDEs like Eclipse and IntelliJ IDEA communicate with source code repositories like
GitHub and Sourceforge.
• Word processors like Microsoft Word open files from URLs.
• Antivirus programs like Norton AntiVirus check for new virus definitions by con‐
necting to the vendor’s website every time the computer is started.
• Music players like Winamp and iTunes upload CD track lengths to CDDB and
download the corresponding track titles.
• Gamers playing multiplayer first-person shooters like Halo gleefully frag each other
in real time.
• Supermarket cash registers running IBM SurePOS ACE communicate with their
store’s server in real time with each transaction. The server uploads its daily receipts
to the chain’s central computers each night.
• Schedule applications like Microsoft Outlook automatically synchronize calendars
among employees in a company.
Java was the first programming language designed from the ground up for network
applications. Java was originally aimed at proprietary cable television networks rather
than the Internet, but it’s always had the network foremost in mind. One of the first two
real Java applications was a web browser. As the Internet continues to grow, Java is
uniquely suited to build the next generation of network applications.
1
Exploring the Variety of Random
Documents with Different Content
nine and ten o'clock. I will not be positive about that. It might have
been earlier, and it might have been later. I think, though, between
nine and ten o'clock in the morning.
Q. Did he state exactly where he found him?
A. He said he had followed him beyond Sharpsburg, and dismounted
from his carriage, and had marched on foot with him for some
distance. Had communicated the order that he has stated. Had
conversed with him for some time, and that General Brinton had
refused to return to Pittsburgh.
Q. Did he say anything about his refusal to join Colonel Guthrie?
A. While I said return to Pittsburgh I meant to join Colonel Guthrie—
that was implied. That after they joined, that is, it was in our minds,
after they had united their commands, that they were to return to
Pittsburgh; but when I said refused to return to Pittsburgh, I meant
refused to join Colonel Guthrie, or rather to execute the order that
Colonel Norris had to carry.
Q. Did he say anything about the condition of General Brinton's
troops?
A. Perhaps he may have mentioned it in a general way, but 1 do not
recollect that he specified it particularly.
Q. That was not spoken of?
A. I think not. At least that did not impress itself on my mind, if it
was mentioned.
Q. Anything said about getting provisions to them?
A. Well, there probably was, but I am not prepared to say what it
was—that was a matter that was paramount in all our minds, the
matter of provisions for the troops had been concerning me,
particularly, from the evening before, and continued to concern me
until the next evening, until I secured some provisions and got them
to the troops.
Q. Is that all that you know in relation to what occurred between
Colonel Norris and General Brinton?
A. That is all, I believe, sir.
Colonel Norris: I would like to say, when I got back to the hotel, Mr.
Cassatt was there, and I believe Mr. Bennett, of Allegheny, and we
had a conversation then about supplying General Brinton's command
with provisions and ammunition, and an arrangement was there
made, I myself giving the directions where he was to convey the
provisions to him, and that provisions did ultimately reach him. That
conversation was heard, I believe, by Colonel Hassinger.
Colonel Smith: If I may be permitted—I was speaking of the time I
met Colonel Norris. I was present at that conversation, at the
Monongahela house, and can verify what the colonel said at that
time.
By Mr. Lindsey:
By Mr. Lindsey:
Q. I would like you to state, general, just what Colonel Norris stated
to you on his return from General Brinton's command?
A. I did detail that, sir, about as fully as I recollect it, describing the
room and situation and surroundings. I will go over it again if you
desire.
Q. I want to ask you one other question. Did you learn on Sunday
that Captain Aull had not reached General Brinton with that order?
A. I did not find it out, sir, until nearly a week afterwards.
Q. When Major Baugh came to the hotel on Sunday, was anything
said to him by you about whether Captain Aull had reached the
command or not?
A. No, sir.
Q. And he did not communicate anything of the kind to you?
A. No, sir.
Q. When you gave the order to Major Baugh, you had no knowledge
whatever of whether Captain Aull had reached General Brinton with
the first order or not?
A. I had not, sir. I supposed he had. I took that for granted.
Captain Aull: Will General Latta add that he gave me no instructions
to report back?
The witness: I did say that in my report.
By Mr. Lindsey:
Q. I wish you to state, general, whether at any time during your stay
in Pittsburgh any attempt was made by any of the officials of the
Pennsylvania Railroad Company to control your movements, or the
movements of your troops in any way?
A. No, sir; there was no attempts made by any officers of the
Pennsylvania Railroad Company, to my knowledge, to dictate or
interfere in the slightest with the movements of the troops. I
remember at one time, just after the firing occurred at Twenty-eight
street, that General Pearson was in Mr. Pitcairn's office, and Mr.
Cassatt was there, one of the vice presidents of the Pennsylvania
railroad, and I asked permission of General Pearson to clear the
streets, and to follow the crowd to the arsenal, and he, more in his
manner than anything else, appealed to Mr. Cassatt, and Mr. Cassatt
said I have nothing to do with the movements of the troops, I know
nothing about that whatever. I can say that at no time did they
attempt, to my knowledge, to interfere in any way with the
movements of the troops.
Q. Will you state from whom, or by whom, the provisions were
delivered to your troops, on the hill beyond Sharpsburg?
A. After our arrival in Pittsburgh, or previous to our arrival, I
telegraphed to Pittsburgh for provisions, to General Pearson, and he
procured them from the Union depot, that is, a sandwich and a cup
of coffee. After that, we were in the round-house, and I made
repeated appeals——
Q. I speak of the provisions that were brought after you went
beyond Sharpsburg, on the hill, when you were encamped there—
from whom you received, the provisions, that is, who delivered them
to you?
A. I had a note from Mr. Cassatt, about, I should think, ten or eleven
o'clock that night, that is, Sunday night, saying that he had procured
for us a lot of hams and provisions, &c, and had sent them out. I
thought, at the time, that Mr. Cassatt had left Pittsburgh, but I found
that he had not, and he had also sent two parties from Sharpsburg,
merchants there, who said that they had an order from Mr. Cassatt
to give us whatever they had in their stores, and they gave me an
inventory of it, and said it was at my disposal, and that Mr. Cassatt
had given them orders, and that he would be responsible for it, and
I might say the only provisions I did receive from the time we went
to Pittsburgh, until we arrived at Blairsville, came through his
energies.
Q. Who delivered the line from Mr. Cassatt to you?
A. My impression was, or is, it was Mr. Smith—Colonel Smith, I think
—who brought it there that night. There is one point I should like to
correct. I won't detail any of the conversation, further than to allude
to my evidence, which I gave before. You have, with Colonel Norris,
stated that I wanted to cross the river and intrench. That I did not
say, and, moreover, it would have been impossible, because I had
not any means of intrenching—no tools, or anything of the kind. He
said he saw no crowd, at all, following to Sharpsburg, and that we
should have remained there, in his idea. I merely refer to a dispatch
which General Latta sent to the Governor at that time, and which he
must have received information either from Captain Aull or Colonel
Norris, as it was sent by telegram. It was directed to Governor
Hartranft, dated July 22, p. 36, in which he says, among other
things: "The first division, after stiff fighting for about fourteen
hours, have retired to a point near Sharpsburg, pursued vigorously
by a mob, to the high bridge at that point, under a hot fire pretty
nearly all the way, but they effectually checked the attack." Colonel
Norris returned, he said that there was no mob following us
whatever.
Q. Go on, general?
A. In regard to our not stopping in Sharpsburg, and that
ammunition, &c, could reach us, I want to state that we went on a
point of the railroad below Sharpsburg, where we could procure
provisions, and where we were in direct communication by rail with
Pittsburgh, the same railroad which runs through Sharpsburg, and
therefore we lost nothing by not stopping in Sharpsburg. In regard
to receiving the provisions which Colonel Norris promised us if we
would remain there, the provisions never came, except by the hands
of the Pennsylvania Railroad Company. The evidence which Colonel
Norris has given in regard to the situation we were in, &c., of course
is entirely different from what I have already stated, and from what
the officers who were immediately surrounding us when he joined us
said. They being on the spot, it was not hearsay evidence on their
part, but it was what they actually heard, and they have sworn that
they were sufficiently near to hear every word that was passed at
the time, but if it is necessary, I can produce those officers to
corroborate it.
Q. We have had that.
Colonel Norris: I wish to ask Colonel Smith, whether the provisions
were not sent in pursuance of the arrangements made after my
conversation with Mr. Cassatt and Mr. Bennett?
By Mr. Lindsey:
You may state that, Colonel Smith.
Colonel Smith: As has already been stated, Mr. Cassatt and Mr.
Bennett, and others, had a consultation at the Monongahela house,
about noon of Sunday. Mr. Bennett and Mr. Cassatt left the hotel
together, Mr. Cassatt, at least, and I think Mr. Bennett with him,
went to Allegheny, to arrange with bakers, and other people there,
to prepare sandwiches and other provisions to send out. I left the
Monongahela house about three o'clock, and had this understanding
with Mr. Cassatt, who was to take the road on the north side of the
river, with the wagons of provisions. I was to move up on the south
side, as stated in my examination in chief. I proceeded by certain
routes across the Allegheny river, and at Aetna, I met Mr. Campbell
Herron, and I stated the necessities of the troops, and asked him
whether he could assist me in procuring provisions for them. I had in
mind the conversation and action taken place at the Monongahela
house, between Mr. Cassatt and others. Mr. Herron said that the
store belonging to their furnace, their property, had some provisions
in it, and he sent for his manager, Mr. Chalfant, and with him I
arranged to load up whatever provisions they had, as soon as it
became dark, and that they should be sent on to the camp of
General Brinton's command. My arrangement with Cassatt, was to
wait at General Brinton's camp until I heard from him—either saw
him or heard from him. After that, I was to proceed to execute the
orders I carried from General Latta, which has already been stated
here to the committee. I waited there until about ten o'clock, when a
man by the name of Bradley, a livery stable keeper—he had charge
of hauling the provisions out there—came into camp, and reported
two wagon loads within a short distance, and in the meantime, Mr.
Chalfant had reported there, that a wagon containing hams, and
some other provisions, which we turned over to the commissary of
General Brinton's command. I believe there is no question about
that, but all these arrangements were made in pursuance of the
understanding arrived at between Mr. Cassatt, and Mr. Bennett and
others, at the instigation of Colonel Norris, after his return from
visiting General Brinton's command in the morning.
At this point the committee adjourned, to meet at the call of the
chairman.
F. B. Gowen, sworn:
By Mr. Lindsey:
By Mr. Larrabee:
By Mr. Means:
Q. Did any of those firemen or engineers who left you at that time,
ever make application to come back?
A. A great many, and it was a very sad thing.
Q. Was there a man by the name of Clarke who made that
application to you personally?
A. I cannot give their names, but a great many have made
application personally.
Q. Didn't you tell him that he had done wrong in being led away by
the Brotherhood?
A. I know of a great many such cases. A great many I knew
expressed a willingness to come back.
Q. And acknowledged to you that they had done wrong, and after
their places had been filled by other parties, wanted to be again in
the employ of the road?
A. A great many—I can hardly give you the number. The point with
the company was this: we had taken on three hundred new men,
and the first duty was to them. And most of those new men are
excellent men. Some of them went to the expense of moving their
families hundreds of miles. Many of the old men have written and
asked to come back, saying that they did wrong, and saying that
they were threatened. Many of them have been very seriously
crippled, by reason of not receiving the pay promised them. I think
that they promised sixty dollars a month to every man who quit the
service of the company.
By Mr. Larrabee:
By Mr. Means:
SAME DAY.
Friday, March 22, 1878—8, P.M.
Pursuant to adjournment, the committee re-assembled at eight
o'clock, P.M., and continued the taking of testimony.
Robert M. Brinton, sworn:
By Mr. Lindsey:
By Senator Yutzy:
By Mr. Means:
Q. On the railroad?
A. Yes. The firing lasted about a minute—not over that, and the
crowd, the moment the firing commenced, or shortly afterwards,
dispersed and went in every direction. I gave the order to cease
firing, and my staff officers had the firing stopped, and the ranks,
which were somewhat broken, were re-formed, and I sent a staff
officer to report to General Pearson. I thought he was on the
ground, because it was not certainly—my opinion is, that in three
minutes after he gave me the order to clear the tracks, the firing
commenced. In the meantime, the Pittsburgh troops on the hill—I
had not discovered them before—quite a number of them threw
down their arms and left. I went up the hill a very short distance,
and I saw what was going on there, and I hunted for General
Pearson; finally, I received a note from him, saying he was at Mr.
Pitcairn's office at the outer depot, and, that if I wished to
communicate with him, to send a staff officer, which I did—Colonel
Wilson—and he came back and said that General Pearson desired to
see me. I turned the command over to General Matthews, and
reported to General Pearson at the office of the Pennsylvania railroad
at the outer depot—Mr. Pitcairn's office. I said to General Pearson at
the time, that I thought we ought to continue to drive the crowd. I
understood that they had gone to the arsenal. Several men came up
to me and said that the crowd had gone to the United States arsenal
to arm themselves, and I thought, when I found that they had gone
away, that they would probably get arms and ammunition, and I
proposed to General Pearson that we should follow the crowd. He
hesitated some time about it, and finally I grew more imperative in
my question, and I said, you must do something, I cannot allow my
men to stand on the track with the crowd pushing around me, and
not be allowed to fire. We will either have to move from there or
attack the crowd. Finally, he said that the Second brigade had been
moved into the round-house and machine shops, because he was
afraid that they would be burned, and then he told me to move my
whole force in, amounting to six hundred men, which I did just at
dusk in the evening. We moved in there. They told me to occupy
one round-house and the machine and upholstery shops and the
lumber-yard, and that General Brown would move into the other
round-house at Twenty-eighth street, and I was not aware he was
not there until I saw the flames. As soon as I went there, the crowd
commenced trying to get into the yard, and I had a guard detailed
and put out, and two of them were shot, one through the arm and
one other through the leg, while on their beats. I then got down the
Gatling guns and prepared to fire them, but thought it would be
courtesy to communicate with General Pearson, and tell him what I
was going to do; which I did, and he prohibited me from doing so.
The crowd were firing pistol balls in at us, and a few rifle balls and a
considerable number of stones. I went to General Pearson, and said,
"I cannot stand it, we must defend ourselves." He said he would go
to the mayor and see him, which would do more good than our
bullets would, as he had a great deal of influence over the elements
predominant then, and said that he did not want to take life
unnecessarily, &c., at the same time we were short of ammunition
and rations, only having twenty rounds, and if we were going to be
in a state of siege, I thought we ought to have a sufficient amount.
General Pearson said he would go and see that we got provisions
and also ammunition, and left, saying he would be back in an hour.
He went through the lumber-yard, and left us. At the same time he
told me to open any dispatches that came for him, and I asked if he
had any new instructions. He said, "I want you to hold the place,"
and after he left I proposed to hold it in the way I thought proper, by
firing into the mob at the gates, which drove them away from there,
so that presently there were only pistol bullets and a few straggling
musket balls. We continued to hold it in that way without receiving
any communications from the other world. I expected General
Pearson back every moment. I didn't want to take it on myself to
move out there, or do anything. About two o'clock in the morning
Colonel Snowden, of the Third regiment, called into the round-
house, and directed my attention to what he considered a piece of
artillery. It was quite dark at the time. We watched it for probably
fifteen minutes, when a cloud cleared away, and we decided it was a
piece of artillery, around which were quite a number of men who
were training the piece. I immediately ordered Colonel Snowden to
get fifty men out, and told him to lower their pieces and fire low,
and I gave the order. They had got the piece finally into a position to
suit themselves, and a man had hold of the lanyard. I gave the order
to fire, and when the smoke cleared away eleven of them were lying
there.
By Mr. Lindsey:
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com