Full Download C network programming Vol 2 Systematic reuse with ACE and frameworks 6. print Edition Schmidt PDF DOCX
Full Download C network programming Vol 2 Systematic reuse with ACE and frameworks 6. print Edition Schmidt PDF DOCX
https://ebookultra.com
https://ebookultra.com/download/c-network-
programming-vol-2-systematic-reuse-with-ace-and-
frameworks-6-print-edition-schmidt/
https://ebookultra.com/download/php-programming-with-pear-1st-edition-
schmidt-stephan/
ebookultra.com
https://ebookultra.com/download/programming-the-network-with-perl-1st-
edition-paul-barry/
ebookultra.com
https://ebookultra.com/download/systematic-instruction-for-students-
with-moderate-and-severe-disabilities-belva-c-collins/
ebookultra.com
https://ebookultra.com/download/programming-in-c-2-e-second-edition-
dey/
ebookultra.com
STL Tutorial and Reference Guide C Programming With the
Standard Template Library 2 (Draft) Edition David R.
Musser
https://ebookultra.com/download/stl-tutorial-and-reference-guide-c-
programming-with-the-standard-template-library-2-draft-edition-david-
r-musser/
ebookultra.com
https://ebookultra.com/download/programming-with-c-zambak-1st-edition-
osman-ay/
ebookultra.com
https://ebookultra.com/download/rapid-french-vol-2-with-audio-second-
edition-earworms/
ebookultra.com
https://ebookultra.com/download/programming-with-visual-c-concepts-
and-projects-1st-edition-james-allert/
ebookultra.com
C network programming Vol 2 Systematic reuse with
ACE and frameworks 6. print Edition Schmidt Digital
Instant Download
Author(s): Schmidt, Douglas C;Huston, Stephen D
ISBN(s): 9780201795257, 0201795256
Edition: 6. print
File Details: PDF, 2.08 MB
Year: 2002
Language: english
C++ Network Programming
Volume 2
The C++ In-Depth Series
Bjarne Stroustrup, Editor
“I have made this letter longer than usual, because I lack the time to make it short.”
—BLAISE PASCAL
T he advent of the ISO/ANSI C++ standard marked the beginning of a new era for C++
programmers. The standard offers many new facilities and opportunities, but how can a
real-world programmer find the time to discover the key nuggets of wisdom within this
mass of information? The C++ In-Depth Series minimizes learning time and confusion by
giving programmers concise, focused guides to specific topics.
Each book in this series presents a single topic, at a technical level appropriate to that
topic. The Series’ practical approach is designed to lift professionals to their next level
of programming skills. Written by experts in the field, these short, in-depth monographs
can be read and referenced without the distraction of unrelated material. The books are
cross-referenced within the Series, and also reference The C++ Programming Language by
Bjarne Stroustrup.
As you develop your skills in C++, it becomes increasingly important to separate essential
information from hype and glitz, and to find the in-depth content you need in order to grow.
The C++ In-Depth Series provides the tools, concepts, techniques, and new approaches to
C++ that will give you a critical edge.
For more information, check out the series web site at www.awprofessional.com/series/indepth/
C++ Network Programming
Volume 2
Douglas C. Schmidt
Stephen D. Huston
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any
kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages
in connection with or arising out of the use of the information or programs contained herein.
The publisher offers discounts on this book when ordered in quantity for bulk purchases and special sales. For more
information, please contact:
International Sales
(317) 581-3793
[email protected]
Schmidt, Douglas C.
C++ network programming / Douglas C. Schmidt, Stephen D. Huston.
p. cm.
Includes bibliographical references and index.
Contents: Vol. 2. Systematic reuse with ACE and frameworks.
ISBN 0-201-79525-6 (v. 2 : pbk.)
1. C++ (Computer program language) 2. Object-oriented programming (Computer
science) 3. Computer networks. I. Huston, Stephen D. II. Title.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form,
or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher.
Printed in the United States of America. Published simultaneously in Canada.
For information on obtaining permission for use of material from this work, please submit a written request to:
ISBN: 0-201-79525-6
2 3 4 5 6 7 8 9 10— O P M—06050403
Second printing, February 2005
Contents
Foreword vii
v
vi CONTENTS
Glossary 319
Bibliography 329
Index 337
Foreword
The ADAPTIVE Communication Environment (ACE) toolkit has achieved enormous suc-
cess in the area of middleware for networked computing. Due to its flexibility, perfor-
mance, platform coverage, and other key properties, ACE enjoys broad acceptance by the
networked application software community, as evidenced by its use in thousands of applica-
tions, in scores of countries, and in dozens of domains. ACE has also received considerable
attention beyond the middleware community since it’s an open-source role model for high-
quality and well-designed pattern-oriented software architectures.
But why is ACE so successful? Addressing this question properly takes some thought.
To start off, let’s reconsider the Foreword from C++ Network Programming: Mastering
Complexity with ACE and Patterns (C++NPv1) and resume the mass transit analogy pre-
sented there by my colleague Steve Vinoski. Steve’s right that a high-quality mass transit
system consists of more than just aircraft, airports, trains, train stations, and rails. It also
needs less obvious infrastructure, such as scheduling, routing, ticketing, maintenance, and
monitoring. But even a complete collection of ingredients is still not sufficient to develop
an effective mass transit system. Arranging these ingredients so they seamlessly fulfill their
primary objective—fast and reliable transportation of people—is equally important. Would
you use a mass transit system whose ticketing was located in a train maintenance location
or an airport hangar, or whose planned and actual scheduling and routing weren’t available
to the public? I doubt it!
The success of mass transit systems depends on more than the knowledge of the infra-
structure parts that are provided—it depends on how these different parts must be connected
and integrated with their environment. This knowledge enables architects of mass transit
systems to integrate individual parts into higher-level building blocks and to connect these
building blocks effectively. For example, ticketing, information points, baggage offices, and
boarding are integrated in train stations located at city centers or major suburban centers.
Likewise, airports are often located near large cities and connected by frequent express
trains.
vii
viii Foreword
Even mass transit centers themselves are arranged so that activities can be performed
effectively. For example, when you enter a train station or airport via the main entrance, you
find ticket agents, information centers, and timetables. You also find shops to satisfy your
travel needs. As you enter the main train hall or airport concourse, you find other informa-
tion centers, up-to-date scheduling information, and the platforms and gates for boarding
the trains and planes. Mass transit centers thus not only provide all necessary services
to begin and end a journey, they also organize their internal “control flows” effectively.
While the core structures and control flows in most train stations and airports are similar,
their concrete realization can differ widely. Yet we all recognize these mass transit center
patterns immediately since they follow key invariants that we’ve learned through years of
experience.
So what’s the connection between successful mass transit system design and the success
of ACE? The answer is simple: In addition to the basic network computing ingredients (the
wrapper facades that Doug and Steve introduced in C++NPv1), ACE also includes use-
ful object-oriented frameworks that build upon these wrapper facades and provide useful
higher-level communication services, such as event demultiplexing and dispatching, con-
nection management, service configuration, concurrency, and hierarchically layered stream
processing. The ACE framework services satisfy many networked software needs by or-
ganizing the structures and internal control flows of your applications effectively via key
patterns learned through years of experience.
The ACE frameworks offer you a number of important benefits:
• You needn’t develop the capabilities provided by ACE, which will save considerable
time and effort. You can therefore focus on your key responsibility: implementing
the application functionality required by your customers and end users.
• The ACE frameworks reify the extensive network programming expertise that Doug,
Steve, and their colleagues have gained over several decades. In particular, the ACE
frameworks efficiently implement the canonical classes, class relationships, and con-
trol flows common to networked applications. The ACE frameworks are tested reg-
ularly by thousands of users from around the world, which has yielded many useful
corrections and improvements. As an ACE user, you can directly leverage the cor-
rectness, effectiveness, and efficiency of the ACE frameworks in your applications.
• A framework isn’t a framework if it can’t be adapted to specific user needs. This
means you can adapt the ACE frameworks at key points of variation in networked
applications. For example, the ACE Reactor framework can be adapted to use dif-
ferent event demultiplexer functions, such as WaitForMultipleObjects() or
select(). Likewise, the ACE Acceptor-Connector framework can be configured
with different IPC mechanisms. While this adaptability is beneficial by itself, ACE
goes a step further: for many adaptations you can configure the desired strategies
from available and interchangeable implementations. In addition to the different Re-
Foreword ix
actor implementations mentioned above, for instance, ACE provides wrapper facades
for various IPC mechanisms, such as the Sockets, SSL, TLI, and shared memory, that
help to configure the ACE Acceptor-Connector framework for specific platforms and
applications.
• Last but not least, the ACE frameworks don’t exist in isolation. You can therefore
combine them in novel ways to create networked applications and entirely new types
of middleware. For example, you can integrate the Reactor framework with the
Acceptor-Connector framework to separate connection establishment from service
processing functionality in event-driven applications. You can likewise introduce
various forms of concurrency into your applications using the ACE Task framework.
As a result of advising and leading many software projects over the years, I’ve found
that ACE greatly simplifies the task of employing reusable middleware that can be cus-
tomized readily to meet the needs of networked applications. Not all networked applica-
tions need heavyweight middleware, such as application servers, web services, and complex
component models. Yet most networked applications can benefit from portable and efficient
host infrastructure middleware like ACE. This flexibility is the core of ACE’s success since
you needn’t commit to an entire middleware suite if you don’t use all of it. Instead, you
can combine just the essential ACE middleware classes you need to compose applications
that are small, but as powerful as necessary. For this reason, I predict that ACE will still be
widely used long after the influence of today’s heavyweight middleware has waned.
ACE’s tremendous flexibility also needn’t lead to a sea of incompatible middleware
implementations. For example, if you build an embedded system that speaks the CORBA
Internet inter-ORB protocol (IIOP) to the outside world, you can use The ACE ORB (TAO),
which is a CORBA-compliant, open-source, real-time object request broker (ORB) built
using the ACE wrapper facades and frameworks. If CORBA is overkill for your application
needs, however, you can build custom, yet interoperable, middleware using the appropriate
ACE classes. Both solutions can be based on the same core structures and protocols, such
as the ACE Common Data Representation (CDR) classes and its TCP/IP Socket wrapper
facades. They can therefore communicate seamlessly with one another, just as you can
take a train from Paris to Istanbul—the famous Orient Express—and travel through many
European countries without having to change trains due to incompatible railroad networks.
As Steve Vinoski and I have pointed out, there are many similarities between high-
quality mass transit systems and high-quality networking middleware. To me and thousands
of other C++ developers around the world, ACE is the toolkit for building the latter! Af-
ter saying so many good things about ACE, however, let’s return to the main intent of this
foreword: introducing the second volume (C++NPv2) of the C++ Network Programming
series. As with all software technologies and middleware, the more you understand your
tools, the better you’ll be able to apply them. It turns out that using ACE in your appli-
cations is just one aspect of improving your networked software. To benefit significantly
x Foreword
from ACE’s many advantages, you therefore also need a sound understanding of the core
concepts, patterns, and usage rules that underlie its powerful frameworks.
For years, a common way to learn ACE involved studying its code, comments, and ex-
ample applications. Clearly, this process was time consuming and error prone. Moreover,
even after managing to read the several hundred thousand lines of C++ code in ACE, it was
easy to miss the forest for the trees. As the Greek philosopher Thucydides noted two mil-
lennia ago: “A man who has the knowledge but lacks the power to clearly express himself
is no better off than if he had never any idea at all.”
We’re therefore fortunate that Doug and Steve found time in their busy schedules to
create such a high-quality book on the ACE frameworks. C++NPv2 explains the ideas
and concepts underlying the ACE frameworks in an easily accessible form using the popu-
lar concurrency and networking patterns from the POSA [POSA1, POSA2] and “Gang of
Four” [GoF] patterns books. These patterns, in turn, reify thoughtful and time-proven solu-
tions to common networking problems. For example, they tell you what the problems are,
why these problems are hard, what the solutions to these problems are, and why these solu-
tions applied to ACE are of high quality. If you want thorough coverage of the patterns and
frameworks in ACE that are shaping the next generation of networked application software
then read this book. I’ve learned much from it and I’m sure you will too.
Frank Buschmann
Senior Principal Engineer
Siemens Corporate Technology
Munich, Germany
About This Book
Software for networked applications must possess the following qualities to be successful
in today’s competitive, fast-paced computing industry:
• Affordability, to ensure that the total ownership costs of software acquisition and
evolution are not prohibitively high
• Extensibility, to support successions of quick updates and additions to address new
requirements and take advantage of emerging markets
• Flexibility, to support a growing range of multimedia data types, traffic patterns, and
end-to-end quality of service (QoS) requirements
• Portability, to reduce the effort required to support applications on heterogeneous
OS platforms and compilers
• Predictability and efficiency, to provide low latency to delay-sensitive real-time ap-
plications, high performance to bandwidth-intensive applications, and usability over
low-bandwidth networks, such as wireless links
• Reliability, to ensure that applications are robust, fault tolerant, and highly available
• Scalability, to enable applications to handle large numbers of clients simultaneously
xi
xii About This Book
This book describes how the ACE frameworks are designed and how they can help
developers navigate between the limitations of
1. Low-level native operating system APIs, which are inflexible and nonportable
2. High-level middleware, such as distribution middleware and common middleware
services, which often lacks the efficiency and flexibility to support networked appli-
cations with stringent QoS and portability requirements
The skills required to produce and use networked application frameworks have traditionally
been locked in the heads of expert developers or buried deep within the source code of
numerous projects that are spread throughout an enterprise or an industry. Neither of these
locations is ideal, of course, since it’s time consuming and error prone to reengineer this
knowledge for each new application or project. To address this problem, this book illustrates
the key patterns [POSA2, POSA1, GoF] that underlie the structure and functionality of the
ACE frameworks. Our coverage of these patterns also makes it easier to understand the
design, implementation, and effective use of the open-source ACE toolkit itself.
Intended Audience
This book is intended for “hands on” C++ developers or advanced students interested in
understanding how to design object-oriented frameworks and apply them to develop net-
worked applications. It builds upon material from C++NPv1 that shows how developers
can apply patterns to master complexities arising from using native OS APIs to program
networked applications. It’s therefore important to have a solid grasp of the following top-
ics covered in C++NPv1 before reading this book:
• Networked application design dimensions, including the alternative communica-
tion protocols and data transfer mechanisms discussed in Chapter 1 of C++NPv1
• Internet programming mechanisms, such as TCP / IP connection management and
data transfer APIs [Ste98] discussed in Chapter 2 of C++NPv1
• Concurrency design dimensions, including the use of processes and threads, iter-
ative versus concurrent versus reactive servers, and threading models [Ste99] dis-
cussed in Chapters 5 through 9 of C++NPv1
• Synchronization techniques necessary to coordinate the interactions of processes
and threads on various OS platforms [KSS96, Lew95, Ric97] discussed in Chapter
10 of C++NPv1
• Object-oriented design and programming techniques [Boo94, Mey97] that can
simplify OS APIs and avoid programming mistakes through the use of patterns, such
as Wrapper Facade [POSA2] and Proxy [POSA1, GoF] discussed in Chapter 3 and
Appendix A of C++NPv1
xiv About This Book
The ACE frameworks are highly flexible and powerful, due in large part to their use of
C++ language features [Bja00]. You should therefore be familiar with C++ class inheritance
and virtual functions (dynamic binding) as well as templates (parameterized types) and
the mechanisms your compiler(s) offer to instantiate them. ACE provides a great deal of
assistance in overcoming differences between C++ compilers. As always, however, you
need to know the capabilities of your development tools and how to use them. Knowing
your tools makes it easier to follow the source code examples in this book and to build and
run them on your systems. Finally, as you read the examples in this book, keep in mind the
points noted in Sidebar 7 (page 46) regarding UML diagrams and C++ code.
• Chapter 3 describes the design and use of the ACE Reactor framework, which imple-
ments the Reactor pattern [POSA2] to allow event-driven applications to demultiplex
and dispatch service requests that are delivered to an application from one or more
clients.
• Chapter 4 then describes the design and use of the most common implementations
of the ACE_Reactor interface, which support a wide range of OS event demul-
tiplexing mechanisms, including select(), WaitForMultipleObjects(),
XtAppMainLoop(), and /dev/poll.
• Chapter 5 describes the design and use of the ACE Service Configurator framework.
This framework implements the Component Configurator pattern [POSA2] to allow
an application to link/unlink its component service implementations at run time with-
out having to modify, recompile, or relink the application statically.
• Chapter 6 describes the design and effective use of the ACE Task framework. This
framework can be used to implement key concurrency patterns, such as Active Object
and Half-Sync/Half-Async [POSA2].
• Chapter 7 describes the design and effective use of the ACE Acceptor-Connector
framework. This framework implements the Acceptor-Connector pattern [POSA2] to
decouple the connection and initialization of cooperating peer services in a networked
system from the processing they perform once connected and initialized.
• Chapter 8 describes the design and use of the ACE Proactor framework. This frame-
work implements the Proactor and Acceptor-Connector patterns [POSA2] to allow
event-driven applications to efficiently demultiplex and dispatch service requests trig-
gered by the completion of asynchronously initiated operations.
• Chapter 9 describes the design and use of the ACE Streams framework. This frame-
work implements the Pipes and Filters pattern [POSA1] to provide a structure for
systems that process streams of data.
• The book concludes with a glossary of technical terms, a list of references for further
study, and a general subject index.
The chapters are organized to build upon each other and to minimize forward references.
We therefore recommend that you read the chapters in order.
Although this book illustrates the key capabilities of ACE’s most important frameworks,
we don’t cover all uses and methods of those frameworks. For additional coverage of ACE,
we refer you to The ACE Programmer’s Guide [HJS] and the online ACE reference doc-
umentation, generated by Doxygen [Dim01]. ACE’s reference documentation is available
at http://ace.ece.uci.edu/Doxygen/ and http://www.riverace.com/
docs/.
xvi About This Book
Related Material
This book is based on ACE version 5.3, released in the fall of 2002. ACE 5.3 and all the
sample applications described in our books are open-source software. Sidebar 3 (page 19)
explains how you can obtain a copy of ACE so you can follow along, see the actual ACE
classes and frameworks in complete detail, and run the code examples interactively as you
read the book.
To learn more about ACE, or to report errors you find in the book, we recommend you
subscribe to the ACE mailing list, [email protected]. You can subscribe by
sending a request to [email protected]. Include the following
command in the body of the e-mail (the subject is ignored):
subscribe ace-users [emailaddress@domain]
You must supply emailaddress@domain only if your message’s From address is not
the address you wish to subscribe. If you use this alternate address method, the list server
will require an extra authorization step before allowing you to join the list.
Postings to the ace-users list are also forwarded to the comp.soft-sys.ace
USENET newsgroup, along with postings to several other ACE-related mailing lists. Read-
ing the messages via the newsgroup is a good way to keep up with ACE news and activity
if you don’t require immediate delivery of the 30 to 50 messages that are posted daily on
the mailing lists.
Archives of postings to the comp.soft-sys.ace newsgroup are available at http:
//groups.google.com/. Enter comp.soft-sys.ace in the search box to go to
a list of archived messages. Google has a complete, searchable archive of over 40,000
messages. You can also post a message to the newsgroup from Google’s site.
Acknowledgments
Champion reviewing honors go to Alain Decamps, Don Hinton, Alexander Maack, Chris
Uzdavinis, and Johnny Willemsen, who reviewed the book multiple times and provided ex-
tensive, detailed comments that improved its form and content substantially. Many thanks
also to the official reviewers, Timothy Culp, Dennis Mancl, Phil Mesnier, and Jason Pa-
sion, who read the entire book and gave us many helpful comments. Many other ACE
users provided feedback on this book, including Marc M. Adkins, Tomer Amiaz, Vi Thuan
Banh, Kevin Bailey, Stephane Bastien, John Dilley, Eric Eide, Andrew Finnell, Dave Find-
lay, Jody Hagins, Jon Harnish, Jim Havlicek, Martin Johnson, Christopher Kohlhoff, Alex
Libman, Harald Mitterhofer, Llori Patterson, Nick Pratt, Dieter Quehl, Tim Rozmajzl, Irma
Rastegayeva, Eamonn Saunders, Harvinder Sawhney, Christian Schuhegger, Michael Sear-
les, Kalvinder Singh, Henny Sipma, Stephen Sturtevant, Leo Stutzmann, Tommy Svensson,
Bruce Trask, Dominic Williams, and Vadim Zaliva.
About This Book xvii
We are deeply indebted to all the members, past and present, of the DOC groups at
Washington University in St. Louis and the University of California, Irvine, as well as the
team members at Riverace Corporation and Object Computing Inc., who developed, refined,
and optimized many of the ACE capabilities presented in this book. This group includes Ev-
erett Anderson, Alex Arulanthu, Shawn Atkins, John Aughey, Luther Baker, Jaiganesh Bal-
asubramanian, Darrell Brunsch, Don Busch, Chris Cleeland, Angelo Corsaro, Chad Elliot,
Sergio Flores-Gaitan, Chris Gill, Pradeep Gore, Andy Gokhale, Priyanka Gontla, Myrna
Harbibson, Tim Harrison, Shawn Hannan, John Heitmann, Joe Hoffert, James Hu, Frank
Hunleth, Prashant Jain, Vishal Kachroo, Ray Klefstad, Kitty Krishnakumar, Yamuna Krish-
namurthy, Michael Kircher, Fred Kuhns, David Levine, Chanaka Liyanaarachchi, Michael
Moran, Ebrahim Moshiri, Sumedh Mungee, Bala Natarajan, Ossama Othman, Jeff Parsons,
Kirthika Parameswaran, Krish Pathayapura, Irfan Pyarali, Sumita Rao, Carlos O’Ryan,
Rich Siebel, Malcolm Spence, Marina Spivak, Naga Surendran, Steve Totten, Bruce Trask,
Nanbor Wang, and Seth Widoff.
We also want to thank the thousands of C++ developers from over 50 countries who’ve
contributed to ACE for over a decade. ACE’s excellence and success is a testament to the
skills and generosity of many talented developers and the forward-looking companies that
had the vision to contribute their work to ACE’s open-source code base. Without their
support, constant feedback, and encouragement, we would never have written this book.
In recognition of the efforts of the ACE open-source community, we maintain a list of all
contributors at http://ace.ece.uci.edu/ACE-members.html.
We are also grateful for the support from colleagues and sponsors of our research
on patterns and development of the ACE toolkit, notably the contributions of Ron Akers
(Motorola), Steve Bachinsky (SAIC), John Bay (DARPA), Detlef Becker (Siemens), Frank
Buschmann (Siemens), Dave Busigo (DARPA), John Buttitto (Sun), Becky Callison (Boe-
ing), Wei Chiang (Nokia Inc.), Joe Cross (Lockheed Martin), Lou DiPalma (Raytheon),
Bryan Doerr (Savvis), Karlheinz Dorn (Siemens), Scott Ellard (Madison), Matt Emerson
(Escient Convergence Group, Inc.), Sylvester Fernandez (Lockheed Martin), Nikki Ford
(DARPA), Andreas Geisler (Siemens), Helen Gill (NSF), Inc.), Jody Hagins (ATD), Andy
Harvey (Cisco), Sue Kelly (Sandia National Labs), Gary Koob (DARPA), Petri Koske-
lainen (Nokia Inc.), Sean Landis (Motorola), Patrick Lardieri (Lockheed Martin), Doug Lea
(SUNY Oswego), Joe Loyall (BBN), Kent Madsen (EO Thorpe), Ed Margand (DARPA),
Mike Masters (NSWC), Major Ed Mays (U.S. Marine Corps), John Mellby (Raytheon),
Jeanette Milos (DARPA), Stan Moyer (Telcordia), Ivan Murphy (Siemens), Russ Nose-
worthy (Object Sciences), Adam Porter (U. of Maryland), Dieter Quehl (Siemens), Vi-
jay Raghavan (Vanderbilt U.), Lucie Robillard (U.S. Air Force), Craig Rodrigues (BBN),
Rick Schantz (BBN), Andreas Schulke (Siemens), Steve Shaffer (Kodak), Tom Shields
(Raytheon), Dave Sharp (Boeing), Naval Sodha (Ericsson), Paul Stephenson (Ericsson),
Tatsuya Suda (UCI), Umar Syyid (Storetrax, Inc.), Janos Sztipanovits (Vanderbilt U.), Gau-
tam Thaker (Lockheed Martin), Lothar Werzinger (Krones), and Don Winter (Boeing).
xviii About This Book
Very special thanks go to Susan Cooper, our copy editor, for enhancing our written
material. In addition, we are grateful for the encouragement and patience of our editor,
Debbie Lafferty, our production coordinator, Elizabeth Ryan, the series editor and inventor
of C++, Bjarne Stroustrup, and everyone else at Addison-Wesley who made it possible to
publish this book.
Finally, we would also like to acknowledge our gratitude and indebtedness to the late
W. Richard Stevens, the father of network programming literature. The following poem by
Samuel Butler sums up our view of Richard’s enduring influence:
Steve’s Acknowledgments
Wow. . . C++NPv1 took almost 3 years to complete—this volume took roughly nine months.
Thank you to my wife Jane who cheerfully endured this process. Your persistent exhorta-
tion to keep life in balance and “be the tortoise” really helped me stay the course, and
without your infinite patience through many long days and nights, I would not have com-
pleted this—thank you! Thanks to Doug Schmidt for getting the bulk of this book down
and organized in world-class time amidst a full-time job and his usual, amazing amount
of work on ACE. Finally, thank you to Riverace’s customers who supported this work so
enthusiastically. It’s a privilege to serve you.
Doug’s Acknowledgments
I’d like to thank my wife Sonja and my parents for their love and support during the writing
of this book. Now that it’s done we’ll have lots more time to have fun! Thanks also to Steve
Huston, who time-shared his overloaded schedule to wrap up the book. I’d also like to thank
my friends and colleagues at the College of William and Mary; Washington University, St.
Louis; University of California, Irvine; Vanderbilt University; DARPA; and Siemens—as
well as the thousands of ACE and TAO developers and users worldwide—who have greatly
enriched my intellectual and interpersonal life over the past two decades. I look forward to
working with all of you in the future.
C HAPTER 1
C HAPTER S YNOPSIS
Object-oriented frameworks help reduce the cost and improve the quality of networked ap-
plications by reifying software designs and pattern languages that have proven effective in
particular application domains. This chapter illustrates what frameworks are and compares
them with other popular software development techniques, such as class libraries, compo-
nents, patterns, and model-integrated computing. It then illustrates the process of applying
frameworks to networked applications and outlines the ACE frameworks that are the fo-
cus of this book. These frameworks are based on a pattern language [POSA1, POSA2]
that has been applied to thousands of production networked applications and middleware
worldwide.
1
2 CHAPTER 1 Object-Oriented Frameworks for Network Programming
• Opportunistic reuse, in which developers cut and paste code from existing programs
to create new ones. Opportunistic reuse works in a limited way for individual pro-
grammers or small groups. It doesn’t scale up across business units or enterprises,
however, and therefore doesn’t significantly reduce development cycle time and cost
or improve software quality. Worse, opportunistic reuse can actually impede devel-
opment progress since cut-and-paste code often begins to diverge as it proliferates,
forcing developers to fix the same bugs multiple times in multiple places.
• Systematic reuse, which is an intentional and concerted effort to create and apply
multiuse software architectures, patterns, frameworks, and components throughout
a product line [CN02]. In a well-honed systematic reuse process, each new project
leverages time-proven designs and implementations, only adding new code that’s spe-
cific to a particular application. This type of reuse is essential to increase software
productivity and quality by breaking the costly cycle of rediscovering, reinventing,
and revalidating common software artifacts.
Middleware [SS02] is a class of software that can increase systematic reuse levels
significantly by functionally bridging the gap between the end-to-end functional require-
ments of networked applications and the underlying operating systems and network pro-
tocol stacks. Middleware provides capabilities that are critical to networked applications
because they automate common network programming tasks. Developers who use mid-
dleware can therefore program their networked applications more like stand-alone applica-
tions, rather than wrestling with the many tedious and error-prone details associated with
low-level OS event demultiplexing, message buffering and queueing, marshaling and de-
marshaling, and connection management mechanisms. Popular examples of middleware
include Java virtual machines (JVMs), Enterprise JavaBeans (EJB), .NET, the Common
Object Request Broker Architecture (CORBA), and the ADAPTIVE Communication Envi-
ronment (ACE).
Systematically developing high-quality, reusable middleware for networked applica-
tions presents many hard technical challenges, including
• Detecting and recovering from transient and partial failures of networks and hosts in
an application-independent manner
• Minimizing the impact of latency and jitter on end-to-end application performance
• Determining how to partition a distributed application into separate component ser-
vices
• Deciding where and when to distribute and load balance services in a network
Since reusable middleware is inherently abstract, it’s hard to validate its quality and to man-
age its production. Moreover, the skills required to develop, deploy, and support reusable
networked application middleware have traditionally been a “black art,” locked in the heads
of expert developers and architects. These technical impediments to systematic reuse are of-
ten exacerbated by a myriad of nontechnical impediments [Hol97], such as organizational,
Section 1.1 An Overview of Object-Oriented Frameworks 3
Networking Event
loop
Callbacks GUI
Application- Domain-specific
specific Callbacks framework
functionality capabilities
Event
loop
Callbacks
Event
Database
loop
the events. The use of virtual hook methods in the handler classes decouples the applica-
tion’s classes from the framework, allowing each to be changed independently as long as
the interface signature and interaction protocols aren’t modified.
A framework is a “semi-complete” application that programmers can customize to form
complete applications by inheriting from and instantiating classes in the framework. Inheri-
tance enables the features of framework base classes to be shared selectively by subclasses.
If a base class provides default implementations of its methods, application developers need
only override those virtual methods whose default behavior doesn’t meet their needs.
Since a framework is a semi-complete application, it enables larger-scale reuse of soft-
ware than can be achieved by reusing individual classes or stand-alone functions. The
amount of reuse increases due to a framework’s ability to integrate application-defined and
application-independent classes. In particular, a framework abstracts the canonical control
flow of applications in a domain into families of related classes, which can collaborate to
integrate customizable application-independent code with customized application-defined
code.
Local
Application- invocations Math Event
Networking
specific classes loop
functionality
ADT Callbacks GUI
classes
Application-specific
Database
event handler Callbacks
classes
functionality
Event
GUI loop
classes Callbacks
Glue
Event Network Event
code Database
loop IPC classes loop
Frameworks can be classified in terms of the techniques used to extend them, which
range along a continuum from whitebox frameworks to blackbox frameworks [HJE95],
as described below:
• Whitebox frameworks. Extensibility is achieved in a whitebox framework via
object-oriented language features, such as inheritance and dynamic binding.
Existing functionality can be reused and customized by inheriting from frame-
work base classes and overriding predefined hook methods [Pre95] using pat-
terns such as Template Method [GoF], which defines an algorithm with some
steps supplied by a derived class. To extend a whitebox framework, application
developers must have some knowledge of its internal structure.
• Blackbox frameworks. Extensibility is achieved in a blackbox framework by
defining interfaces that allow objects to be plugged into the framework via
composition and delegation. Existing functionality can be reused by defin-
ing classes that conform to a particular interface and then integrating these
classes into the framework using patterns such as Function Object [Kuh97],
Bridge/Strategy [GoF], and Pluggable Factory [Vli98b, Vli99, Cul99], which pro-
vide a blackbox abstraction for selecting one of many implementations. Black-
box frameworks can be easier to use than whitebox frameworks since appli-
cation developers need less knowledge of the framework’s internal structure.
Blackbox frameworks can also be harder to design, however, since framework
developers must define crisp interfaces that anticipate a range of use cases.
Another way that class libraries differ from frameworks is that the classes in a library
are typically passive since they perform their processing by borrowing the thread from so-
called self-directed applications that invoke their methods. As a result, developers must
continually rewrite much of the control logic needed to bind the reusable classes together to
form complete networked applications. In contrast, frameworks are active since they direct
the flow of control within an application via various callback-driven event handling patterns,
such as Reactor [POSA2] and Observer [GoF]. These patterns invert the application’s flow
of control using the Hollywood Principle: “Don’t call us, we’ll call you” [Vli98a]. Since
frameworks are active and manage the application’s control flow, they can perform a broader
range of activities on behalf of applications than is possible with passive class libraries.
Frameworks and class libraries are complementary technologies in practice. Frame-
works provide a foundational structure to applications. Since frameworks are focused on a
specific domain, however, they aren’t expected to satisfy the broadest range of application
development needs. Class libraries are therefore often used in conjunction within frame-
works and applications to implement commonly needed code artifacts, such as strings, files,
and time/date classes.
Section 1.2 Comparing Software Development and Reuse Techniques 7
Deployment and
configuration
metadata
Trading Logging
Deployment and component component
configuration
mechanism
Containers Containers
Application server
For example, the ACE frameworks use the ACE wrapper facade classes to ensure their
portability. Likewise, applications can use the ACE container classes described in [HJS]
to help implement their event handlers. Whereas the ACE container classes and wrapper
facades are passive, the ACE frameworks are active and provide inversion of control at run
time. The ACE toolkit provides both frameworks and a library of classes to help program-
mers address a range of challenges that arise when developing networked applications.
Traditionally, patterns and pattern languages have been locked in the heads of expert
developers or buried deep within the source code of software applications and systems.
Allowing this valuable information to reside only in these locations is risky and expensive.
Explicitly capturing and documenting patterns for networked applications helps to
• Preserve important design information for programmers who enhance and main-
tain existing software. This information will be lost if it isn’t documented, which can
increase software entropy and decrease software maintainability and quality.
• Guide design choices for developers who are building new applications. Since pat-
terns document the common traps and pitfalls in their domain, they help developers
to select suitable architectures, protocols, algorithms, and platform features without
wasting time and effort (re)implementing solutions that are known to be inefficient
or error prone.
Knowledge of patterns and pattern languages helps to reduce development effort and
maintenance costs. Reuse of patterns alone, however, does not create flexible and effi-
cient software. Although patterns enable reuse of abstract design and architecture knowl-
edge, software abstractions documented as patterns don’t directly yield reusable code. It’s
therefore essential to augment the study of patterns with the creation and use of frame-
works. Frameworks help developers avoid costly reinvention of standard software artifacts
by reifying common patterns and pattern languages and by refactoring common implemen-
tation roles.
ACE users can write networked applications quickly because the frameworks in ACE
implement the core patterns associated with service access, event handling, concurrency,
and synchronization [POSA2]. This knowledge transfer makes ACE more accessible and
directly applicable compared to many other common knowledge transfer activities, such as
seminars, conferences, or design and code reviews. Although these other activities are use-
ful, they are limited because participants must learn from past work of others, and then try
to apply it to their current and future projects. In comparison, ACE provides direct knowl-
edge transfer by embodying framework usage patterns in a powerful toolkit containing both
networked application domain experience and working code.
For example, JAWS [HS99] is a high-performance, open-source, adaptive Web server
built using the ACE frameworks. Figure 1.4 (page 10) illustrates how the JAWS Web server
is structured as a set of collaborating frameworks whose design is guided by the patterns
listed along the borders of the figure. These patterns help resolve common design challenges
that arise when developing concurrent servers, including encapsulating low-level operating
system APIs, decoupling event demultiplexing and connection management from protocol
processing, scaling up server performance via multithreading, minimizing server threading
overhead, using asynchronous I/O effectively, and enhancing server configurability. More
information on the patterns and design of JAWS appears in Chapter 1 of POSA2.
10 CHAPTER 1 Object-Oriented Frameworks for Network Programming
State
Memento
framework filesystem
Component configurator
/home/...
Protocol
Event dispatcher
Acceptor
handler
Protocol
filter
Concurrency
State
Protocol pipeline strategy
framework framework
Integrated
model
Model Platform-
interpreter Executable specific Application
and code specifications code code
synthesizer Integrate and Synthesize
generator
generate
System
constraints
• Provide correctness proofs for various algorithms by analyzing the models automati-
cally and offering refinements to satisfy various constraints.
• Generate code that’s highly dependable and robust since the modeling tools them-
selves can be synthesized from meta-models using provably correct technologies.
• Rapidly prototype new concepts and applications that can be modeled quickly using
this paradigm, compared to the effort required to prototype them manually.
• Reuse domain-specific modeling insights, saving significant amounts of time and
effort, while also reducing application time-to-market and improving consistency and
quality.
As shown in Figure 1.5, the MIC development process uses a set of tools to analyze
the interdependent features of the application captured in a model and determine the feasi-
bility of supporting different QoS requirements in the context of the specified constraints.
Another set of tools then translates models into executable specifications that capture the
platform behavior, constraints, and interactions with the environment. These executable
specifications in turn can be used to synthesize application software.
Earlier efforts at model-based development and code synthesis attempted by CASE
tools generally failed to deliver on their potential for the following reasons [All02]:
• They attempted to generate entire applications, including the infrastructure and the
application logic, which led to inefficient, bloated code that was hard to optimize,
validate, evolve, or integrate with existing code.
• Due to the lack of sophisticated domain-specific languages and associated modeling
tools, it was hard to achieve round-trip engineering, that is, moving back and forth
seamlessly between model representations and the synthesized code.
• Since CASE tools and early modeling languages dealt primarily with a restricted
set of platforms (such as mainframes) and legacy programming languages (such as
COBOL), they did not adapt well to the distributed computing paradigm that arose
12 CHAPTER 1 Object-Oriented Frameworks for Network Programming
Many of the limitations with model-integrated computing outlined above can be over-
come by integrating MIC tools and processes with object-oriented frameworks [GSNW02].
This integration helps to overcome problems with earlier-generation CASE tools since it
does not require the modeling tools to generate all the code. Instead, large portions of ap-
plications can be composed from reusable, prevalidated framework classes. Likewise, inte-
grating MIC with frameworks helps address environments where application requirements
and functionality change at a rapid pace by synthesizing and assembling newer extended
framework classes and automating the configuration of many QoS-critical aspects, such as
concurrency, distribution, transactions, security, and dependability.
The combination of model-integrated computing with frameworks, components, and
patterns is an area of active research [Bay02]. In the DOC group, for example, there are
R&D efforts underway to develop a MIC tool suite called the Component Synthesis with
Model-Integrated Computing (CoSMIC) [GSNW02]. CoSMIC extends the popular GME
modeling and synthesis tools [LBM+ 01] and the ACE ORB (TAO) [SLM98] to support
the development, assembly, and deployment of QoS-enabled networked applications. To
ensure the QoS requirements can be realized in the middleware layer, CoSMIC’s model-
integrated computing tools can specify and analyze the QoS requirements of application
components in their accompanying metadata.
HI
HOST INFRASTRUCTURE MIDDLEWARE
SOCKETS & TLI
LEVEL OF USER
open()/close()/putmsg()/getmsg() SPACE
ABSTRACTION
TPI
STREAMS NPI
KERNEL
SPACE
LO FRAMEWORK DLPI
Figure 1.6: Levels of Abstraction for Network Programming
Capability Description
Local endpoint Create and destroy local communication endpoints, allowing ac-
management cess to available networking facilities.
Connection establishment Enable applications to establish connections actively or passively
and connection with remote peers and to shutdown all or part of the connections
termination when transmissions are complete.
Options management Negotiate and enable/disable protocol and endpoint options.
Data transfer mechanisms Exchange data with peer applications.
Name/address translation Convert human-readable names to low-level network addresses
and vice versa.
These capabilities are covered in Chapter 2 of C++NPv1 in the context of the Socket API.
14 CHAPTER 1 Object-Oriented Frameworks for Network Programming
Many IPC APIs are modeled loosely on the UNIX file I/O API, which defines the
open(), read(), write(), close(), ioctl(), lseek(), and select() func-
tions [Rit84]. Due to syntactic and semantic differences between file I/O and network I/O,
however, networking APIs provide additional functionality that’s not supported directly by
the standard UNIX file I/O APIs. For example, the pathnames used to identify files on a
UNIX system aren’t globally unique across hosts in a heterogeneous distributed environ-
ment. Different naming schemes, such as IP host addresses and TCP / UDP port numbers,
have therefore been devised to uniquely identify communication endpoints used by net-
worked applications.
Host infrastructure middleware frameworks. Many networked applications exchange
messages using synchronous and/or asynchronous request/response protocols in conjunc-
tion with host infrastructure middleware frameworks. Host infrastructure middleware en-
capsulates OS concurrency and IPC mechanisms to automate many low-level aspects of
networked application development, including
• Connection management and event handler initialization
• Event detection, demultiplexing, and event handler dispatching
• Message framing atop bytestream protocols, such as TCP
• Presentation conversion issues involving network byte ordering and parameter mar-
shaling and demarshaling
• Concurrency models and synchronization of concurrent operations
• Networked application composition from dynamically configured services
• Hierarchical structuring of layered networked applications and services
• Management of quality of service (QoS) properties, such as scheduling access to
processors, networks, and memory
The increasing availability and popularity of high-quality and affordable host infrastructure
middleware is helping to raise the level of abstraction at which developers of networked
applications can work effectively. For example, [C++NPv1, SS02] present an overview of
higher-level distributed object computing middleware, such as CORBA [Obj02] and The
ACE ORB (TAO) [SLM98], which is an implementation of CORBA built using the frame-
works and classes in ACE. It’s still useful, however, to understand how lower level IPC
mechanisms work to fully comprehend the challenges that arise when designing, porting,
and optimizing networked applications.
NETWORKED
JAWS ADAPTIVE
SERVICE WEB SERVER
COMPONENTS STANDARDS-BASED MIDDLEWARE
LAYER THE ACE ORB
(TAO)
TOKEN GATEWAY
SERVER SERVER
C++ PROCESS/
STREAMS LOG
WRAPPER THREAD
SERVICE
SHARED
MALLOC
MANAGERS MSG
FACADE REACTOR/
CONFIGU-
RATOR
LAYER SYNCH SPIPE SOCK SAP/ FIFO PROACTOR MEM FILE
WRAPPERS SAP TLI SAP SAP MAP SAP
OS ADAPTATION LAYER
C
PROCESSES/
WIN32 NAMED
SOCKETS/ UNIX SELECT/ DYNAMIC SHARED FILE SYS
APIs THREADS
PIPES & UNIX
TLI FIFOS IO COMP LINKING MEMORY APIS
STREAM PIPES
www.riverace.com/. The core ACE library contains roughly a quarter million lines
of C++ code that comprises approximately 500 classes. Many of these classes cooperate to
form ACE’s major frameworks. The ACE toolkit also includes higher-level components, as
well as a large set of examples and an extensive automated regression test suite.
To separate concerns, reduce complexity, and permit functional subsetting, ACE is de-
signed using a layered architecture [POSA1], shown in Figure 1.7. The capabilities pro-
vided by ACE span the session, presentation, and application layers in the OSI reference
model [Bla91]. The foundation of the ACE toolkit is its combination of an OS adaptation
layer and C++ wrapper facades, which together encapsulate core OS network programming
mechanisms to run portably on all the OS platforms shown in Sidebar 2 (page 16). The
higher layers of ACE build on this foundation to provide reusable frameworks, networked
service components, and standards-based middleware.
Acceptor-
Reactor Proactor
Connector
Service
Streams Task
Configurator
ACE users in the form of expertise embodied in well-tested and reusable C++ software
artifacts. The ACE frameworks implement a pattern language for programming concurrent
object-oriented networked applications. Figure 1.8 illustrates the ACE frameworks. To
illustrate how the ACE frameworks rely on and use each other, the lines between boxes
represent a dependency in the direction of the arrow. Each framework is outlined below.
ACE Reactor and Proactor frameworks. These frameworks implement the Reactor and
Proactor patterns [POSA2], respectively. Both are architectural patterns that allow appli-
cations to be driven by events that are delivered to the application from one or more event
sources, the most important of which are I/O endpoints. The Reactor framework facilitates
a reactive I/O model, with events signaling the ability to begin a synchronous I/O opera-
tion. The Proactor framework is designed for a proactive I/O model where one or more
asynchronous I/O operations are initiated and the completion of each operation triggers an
event. Proactive I/O models can achieve the performance benefits of concurrency without
incurring many of its liabilities. The Reactor and Proactor frameworks automate the detec-
tion, demultiplexing, and dispatching of application-defined handlers in response to many
Section 1.4 A Tour through the ACE Frameworks 17
types of events. Chapters 3 and 4 describe the ACE Reactor framework and Chapter 8
describes the ACE Proactor framework.
ACE Task framework. This framework implements various concurrency patterns, such
as Active Object and Half-Sync/Half-Async [POSA2]. Active Object is a design pattern
that decouples the thread that executes a method from the thread that invoked it. Its purpose
is to enhance concurrency and simplify synchronized access to objects that reside in their
own threads of control. Half-Sync/Half-Async is an architectural pattern that decouples
asynchronous and synchronous processing in concurrent systems, to simplify programming
without reducing performance unduly. This pattern incorporates two intercommunicating
layers, one for asynchronous and one for synchronous service processing. A queueing
layer mediates communication between services in the asynchronous and synchronous lay-
ers. Chapter 5 of C++NPv1 describes the design dimensions associated with concurrent
networked applications and Chapter 6 of this book describes the ACE Task framework.
ACE Streams framework. This framework implements the Pipes and Filters pattern,
which is an architectural pattern that provides a structure for systems that process a stream
of data [POSA1]. The ACE Streams framework simplifies the development and compo-
sition of hierarchically layered services, such as user-level protocol stacks and network
management agents [SS94]. Chapter 9 describes this framework.
When used together, the ACE frameworks outlined above enable the development of
networked applications that can be updated and extended without the need to modify, re-
18 CHAPTER 1 Object-Oriented Frameworks for Network Programming
Application-specific
Local
event handler Callbacks
invocations
functionality
Event
IPC loop
classes Callbacks
Event
ACE reactor
loop
Figure 1.9: Applying Class Libraries to Develop and Use ACE Frameworks
compile, relink, or restart running applications. ACE achieves this unprecedented flexibility
and extensibility by combining
• OS mechanisms, such as event demultiplexing, IPC, dynamic linking, multithread-
ing, multiprocessing, and synchronization [Ste99]
• C++ language features, such as templates, inheritance, and dynamic binding [Bja00]
• Patterns, such as Component Configurator [POSA2], Strategy [GoF], and Han-
dler/Callback [Ber95]
The ACE frameworks provide inversion of control via callbacks, as shown below:
The callback methods in ACE’s framework classes are defined as C++ virtual methods.
This use of dynamic binding allows networked applications to freely implement and extend
interface methods without modifying or rebuilding existing framework classes. In contrast,
the ACE wrapper facades rarely use callbacks or virtual methods, so they aren’t as exten-
sible as the ACE frameworks. The ACE wrapper facades do support a broad range of use
Section 1.5 Example: A Networked Logging Service 19
cases, however, and can be integrated together via generic programming [Ale01] techniques
based on the C++ traits and traits classes idioms outlined in Sidebar 40 (page 165).
Figure 1.9 illustrates how the class libraries and frameworks in ACE are complemen-
tary technologies. The ACE toolkit simplifies the implementation of its frameworks via
its class libraries of containers, which include lists, queues, hash tables, strings, and other
reusable data structures. Likewise, application-defined code invoked by event handlers in
the ACE Reactor framework can use the ACE wrapper facades and the C++ standard library
classes [Jos99] to perform IPC, synchronization, file management, and string processing op-
erations. Sidebar 3 describes how to build the ACE library so that you can experiment with
the examples we present in this book.
illustrate key points and ACE capabilities throughout this book by extending and enhancing
the networked logging service example introduced in C++NPv1, which collects and records
diagnostic information sent from one or more client applications.
The logging service in C++NPv1 used many of ACE’s wrapper facades in a two-tier
client/server architecture. This book’s logging service examples use a more powerful archi-
tecture that illustrates a broader complement of capabilities and patterns, and demonstrates
how ACE’s frameworks can help achieve efficient, predictable, and scalable networked ap-
plications. This service also helps to demonstrate key design and implementation consider-
ations and solutions that will arise when you develop your own concurrent object-oriented
networked applications.
Figure 1.10 illustrates the application processes and daemons in our networked logging
service, which we outline below.
Client application processes (such as P1 , P2 , and P3 ) run on client hosts and generate log
records ranging from debugging messages to critical error messages. The logging informa-
tion sent by a client application contains the time the log record was created, the process
identifier of the application, the priority level of the log record, and a variable-sized string
containing the log record text message. Client applications send these log records to a client
logging daemon running on their local host.
Client logging daemons run on every host machine participating in the networked logging
service. Each client logging daemon receives log records from that host’s client applications
via some form of local IPC mechanism, such as shared memory, pipes, or sockets. The
client logging daemon uses a remote IPC mechanism, such as TCP / IP, to forward log records
to a server logging daemon running on a designated host.
Server logging daemons collect and output the incoming log records they receive from
client applications via client logging daemons. A server logging daemon 2 can determine
which client host sent each message by using addressing information it obtains from the
underlying Socket API. There’s generally one server logging daemon per system configu-
ration, though they could be replicated to avoid a single point of failure.
Figure 1.11 (page 22) shows the progression of networked application servers that we’ll
develop and use in this book. These client and server logging daemons will illustrate how
to use the ACE frameworks and wrapper facades with the following concurrency models.
Concurrency Model Section
Reactive 3.5, 4.2, 5.4
Thread pool 4.3, 4.4, 6.3
Thread-per-connection 7.2, 7.3
Producer/consumer 6.2, 7.4, 9.2
Proactive 8.2 – 8.5
2
We use the terms server logging daemon and logging server interchangeably throughout this book.
Section 1.6 Summary 21
Console
Server logging Storage
Local IPC daemon device
Client TCP connection
P1 logging Tango Mambo
daemon
P2
TCP connection
P3
Printer
Server
Network
Client Client P1
Tango logging
daemon
P2
Local IPC P3
Client Mambo
int spawn (void){
if (ACE_OS::fork()==-1)
ACE_ERROR((LM_ERROR, if (Options::instance()->debug())
"unable to fork in function spawn")); ACE_DEBUG((LM_DEBUG,
"sending request to server%s",
server_host));
1.6 Summary
Networked application software has been developed manually from scratch for decades.
The continual rediscovery and reinvention of core concepts and capabilities associated with
this process has kept the costs of engineering and evolving networked applications too high
for too long. Improving the quality and quantity of systematic software reuse is essential to
resolve this problem.
Middleware is a class of software that’s particularly effective at providing systemati-
cally reusable artifacts for networked applications. Developing and using middleware is
therefore an important way to increase reuse. There are many technical and nontechni-
cal challenges that make middleware development and reuse hard, however. This chapter
described how object-oriented frameworks can be applied to overcome many of these chal-
22 CHAPTER 1 Object-Oriented Frameworks for Network Programming
Reactive
Logging Server
(Chapters 3, 4)
Acceptor- Producer/
Proactive
Connector Consumer
Client
Client Client
Logging
Logging Logging
Daemon
Daemon Daemon
(Chapter 8)
(Chapter 7) (Chapter 6)
C HAPTER S YNOPSIS
A service is a set of functionality offered to a client by a server. Common services available
on the Internet today include
23
24 CHAPTER 2 Service and Configuration Design Dimensions
select()
SVC1 SVC2 SVC3
SVC1 SVC2
select()
Logging service ⇒ From the standpoint of an individual log record, our server logging
daemon seems like a short-duration service. Each log record is limited to a maximum length
of 4K bytes, though in practice most are much smaller. The actual time spent handling
a log record is relatively short. Since a client may transmit many log records, however,
we optimize performance by designing client logging daemons to establish connections
with their peer server logging daemons. We then reuse these connections for subsequent
logging requests. It would be wasteful and time consuming to set up and tear down a socket
connection for each logging request, particularly when small requests are sent frequently.
We therefore model our client and server logging daemons as long-duration services.
cess to perform the requested service externally. External services may be more robust than
internal services since the failure of one need not cause the failure of another. To increase
robustness, therefore, mission-critical application services are often isolated in separate pro-
cesses. The price for this robustness, however, can be a reduction in performance due to
process management and IPC overhead.
Some server frameworks support both internal and external services. For example, the
INETD superserver [Ste98] is a daemon that listens for connection requests or messages on
certain ports and runs programs to perform the services associated with those ports. System
administrators can choose between internal and external services in INETD by modifying
the inetd.conf configuration file as follows:
• INETD can be configured to execute short-duration services, such as ECHO and DAY-
TIME , internally via calls to statically linked functions in the INETD program.
• INETD can also be configured to run longer-duration services, such as FTP and TEL -
NET , externally by spawning separate processes.
Sidebar 4 (page 31) describes this and other service provisioning mechanisms that use both
internal and external services.
Logging service ⇒ All logging server implementations in this book are designed as inter-
nal services. As long as only one type of service is configured into our logging server, we
needn’t isolate it from harmful side effects of other services. There are valid reasons to pro-
tect the processing of different client sessions from each other, however, particularly if ser-
vices are linked dynamically using the Component Configurator pattern [POSA2]. Chapter
8 in C++NPv1 therefore illustrates how to implement a logging server as an external service
using the ACE_Process and ACE_Process_Manager classes.
The writer has now pointed out what, in his opinion, is the
Recapitulation.
place which Latin and Greek should take in a girl’s education,
and the methods best calculated to teach them. If in these
there is not much that is new, they are at all events such as experience has
proved to be sound. One or two points may be indicated which are apt to be
weak in girl students, and must therefore be specially guarded against. They
are apt to be shaky in grammar, and they seem
Weak points to be strengthened.
to have less mental self-reliance than boys. As
regards those who learn late, they must go over
the same ground; for no teacher and no book, no not if angels wrote it, can
point out a royal road to learning. These late-learners bring to the task a mind
already more or less trained, and so they will get on faster; but let them
beware of trying to get on too fast. They must make up their minds that
grammar has to be learnt, and work at it with a will. If they have already done
half of the drudgery by learning Latin, as here recommended, their task will be
not easy indeed, but not beyond their powers; and even if both Latin and
Greek are begun late, they need not even then despair. I have known several,
both men and women, who have begun late and ended with success, even
with distinction; although it must be admitted that these were persons of
exceptional powers. But it is of the utmost importance that the most capable
teachers should have charge of the late-learners. The greater the difficulty, the
greater need for a teacher who has his subjects at the ends of his fingers, who
can see a short-cut, and is able to judge how much of the preliminary work
can safely be shortened, or even omitted for the time. When skill in the
teacher meets with will in the taught, between them they may remove
mountains.
LATIN.
Grammar. Composition.
1. Parts of speech and elements: regular 1. Simplest sentences: statement,
nouns and adjectives: est, sunt, and how to question and answer.
form 3rd sing. and pl. pres. indic. first
conjugation, given the infinitive present.
2. Commonest pronouns: present indic. 2. Cases of agent and instrument, time
of sum, and how to form 3rd sing. and pl. and place: quam with nom. and acc., abl. of
of all four conjugations, given the infinitive comparison: a few common prolate verbs:
present. simplest relative sentences and cum
temporal.
3. Pronouns and cardinal numerals: 3. Ablative absolute, and a few more
active of the four conjugations: sum: case usages: accusative with infinitive: use
meanings and case of a few common of se, suus, ipse: double questions:
prepositions. factitives in active, prolate verbs: relative
sentences, with a hint of finals: commands
and prohibitions: causal, concessive and
temporal sentences.
4. Ordinal numerals: passive of the four 4. Quisquam, quisque, quivis, etc.
conjugations: a few common irregular (meaning): chief case usages: factitives:
verbs. common verbs with dative: dependent
questions: accusative with infinitive, tenses
distinguished: simple finals, pos. and
negative: simple consecutives: verbs of
hindering and fearing.
5 and 6. Deponents, impersonals, 5. Utor and other verbs with various
irregular verbs: fill up gaps (add e.g., the cases: all case usages: gerund and
rest of the numerals). gerundive: some impersonal verbs: final
and consecutive sentences: conditions
begun.
6. Quisquam, etc., use and idioms:
participles: nunquam, etc., causal,
concessive, temporal and other
conjunctions: conditions: obliqua.
GREEK.
Grammar. Composition.
1. Regular nouns and adjectives: article: 1. Concords (including that of neuter
εστιν and εισιν: how to form 3rd sing. and plural): article in direct predication: simplest
pl. pres. indic. of verbs in -ω given the sentences, statement, question and
infinitive present. answer: simplest meanings of cases:
meanings of απο, εις, εν, εξ, μετα (gen.),
συν.
2. Some irregular nouns: cardinal 2. Article with demonstrative and with
numerals: comparison of adjectives: adjectives of position: αυτος: simplest
commoner pronouns: ειμι, with active of meaning of the tenses: accusative with
λυω. General rules for accent in its infinitive: some further particles of question
dependence on quantity. and emphasis.
3. Numerals: ειμι, λυω: a few irregular 3. Genitive absolute: agent and
nouns. Accent of nouns and verbs (general instrument and other case usage: infinitive
rules). with verbs of command or request:
commands, prohibitions, wishes (opt.): ἱνα
and its sequence: double questions and
further formulæ.
4. Contracted verbs: parts of a few 4. ὁπως with fut. indic. ὡστε: all final
irregular verbs: accent of nouns and verbs constructions: verbs of fearing: δια, νατα,
(special rules) and contracted syllables. μετα, παρα, προς, ὑπο.
5. Verbs in -μι: οιδα φημι: parts of 5. Accusative and nominative with
commoner irregular verbs. infinitives: use of participles with certain
verbs: consecutive and temporal
constructions: simple indirect statement
and question: the conditions begun.
6. Irregular nouns and verbs: fill gaps. 6. The cases, tenses, participles and
Revise with Goodwin’s Grammar. prepositions: idioms, such as καιπερ ἁτε
ὡς: conditions: all rules of obliqua.
BOOKS.[15]
[15] V is added to those which have vocabularies; K means key.
VERSE.
Manuals by Penrose (elegiacs); Morice (same, more advanced), and Lupton (lyrics): Holden,
Foliorum Silvula (the best anthology).
READERS.
There are numbers of elementary readers, and there is really little to choose between them.
The most useful set seems to the writer to be Rivington’s Single Term Latin Readers, 8d.
to 1/4 each. With notes, exercises and vocabularies. These are sets of three books for
each of six terms, each book containing enough for a term’s work, and each set having
the same standard. Others in common use are: Morice, Loculi, 2/-; Abbott, Dux Latinus,
2/-, adapted to Via Latina; Ritchie, Fabulæ Faciles; Bennett’s Easy Lat. Stories, Hardy’s
Lat. Reader, etc. Teachers and private students may learn much from Abbott’s Latin Gate.
VERSE.
Damon: A Manual of Gr. Iambic Verse (v k), by Williams and Rouse, 2/6. Holden’s Foliorum
Silvula (the best anthology). Help may be obtained from the Greek verse books of
Sidgwick and Morice (v k), (v), Sargent (v), and Kynaston (v), 4/6.
READERS.
Rivington’s Single Term Readers (v), like his Latin readers, 9d. each; recommended. Heatley,
Græcula (v k), 1/6, for beginners. Sidgwick, First Gr. Reading Book (v), 2/6: 100 easy
stories, with some grammar. Rushbrooke, First Gr. Reader (v), 2/6; Bell’s Second Gr.
Reader, 3/-; Murray’s Fourth (specimens of dialects), 4/6, and Abbott’s Fifth (Homer and
the dramatists), 4/6. Macmillan’s Gr. Reader, stories and legends, 3/-. Mayor, First Gr.
Reader, 4/6. The student had better pass on as soon as possible to some such book as
the following: Xenophon, Easy Selections, Philpotts and Jerram. Herodotus, Battle of
Marathon in Attic Prose. Herodotus, Tales from, Atticised, Farnell, 1/6. Arrian: Selections,
Walpole, 1/6. Lucian: Extracts, Bond and Walpole, 1/6. The next step will be to selections
from the Attic Orators: Rivington’s Middle Form Greek Readers, 1/6 each; Plato’s Crito or
Apology; Sidgwick’s Scenes from Greek Plays.
ANTIQUITIES.
Gow, Companion to School Classics; indispensable. Schreiber, Atlas of Class. Antiq., 21/-.
Anderson, Atlas to Homer, 21/-. Rouse, Atlas of Gr. and Rom. Portraits, 1/6 each part.
Macmillan’s Manuals of Antiq., 5/- each. Murray, Handb. of Gr. Archæology, 18/-. J.
Harrison, Mythol. and Monuments of Early Athens. Middleton, Remains of Ancient Rome.
Lanciani, Ruins of Ancient Rome and other works. Schneider, Das Alte Rom. (Pictorial atlas
with maps; excellent.)
MODERN LANGUAGES.
By Dorothea Beale.
SPELLING REFORM.
By Dorothea Beale.
Let me earnestly beg of teachers not to put aside the question of spelling
reform as of little moment, but to do their utmost to bring it about.
Can it be to educators of little moment that learning to read, instead of
introducing children to an orderly system, reveals chaos, and interferes with
the tendency upon which all science is founded to expect law and order. As
Professor Max Müller writes «Every thing that children have to learn in reading
and spelling is irrational; one rule contradicts the other, and each statement
has to be accepted simply on authority, and with a complete disregard of those
rational instincts, which lie dormant in the child, and ought to be awakened by
every kind of healthy exercise».
I find it difficult to express my strong sense of the immense importance of
this reform on grounds educational, economic, patriotic. Not only does our
cacography oppose an enormous obstacle to intellectual progress during the
most important years of mental development, and thus squander brain power
on useless work, it is also a waste of money which is expended by the upper
classes in forcing on the children of the poorer a waste of time and—a sort of
useless prison-labour.
Dr Gladstone calculates that the average board-school child spends more
than 2000 hours in acquiring the arts of reading and spelling, and that the
waste of money is over £ 1000000. This was 20 years ago; with increased
grants, the loss of money must be far more now. He also calculates the waste
of capital in printing unnecessary letters at nearly 20 per cent. This is only one
of the many arguments for reform, which he puts most clearly and forcibly.
Most of the richer children have an indefinite amount of leisure in childhood,
and they forget how long it took to learn to read, but children in elementary
schools groan under a pedantic tyranny, which imposes wearisome and useless
labours upon those who might otherwise in their short school time gain such
facility in reading, that it would be a pleasure ever after, and the time which is
now wasted on spelling, would be available for much beside: Germans have
time to acquire foreign tongues, but Englishmen and Frenchmen have not time
to acquire them in addition to their own spelling; either language from its
simple structure might become a world-wide tongue, and there would be no
need of Volapuk.
I quote from Professor Max Müller’s article.
«According to a Liverpool Schoolmaster of great experience it takes from 6
to 7 years to learn the arts of reading and spelling with a fair amount of
intelligence. I. e. about 2.000 hours. A Glasgow schoolmaster writes, «I have
taught poor children to read the Sermon on the Mount after a course of
exercises extending over no more than 6 hours», and a father writes, «My boy
who is a few months more than 4 will read any phonetic book ... and how long
do you think it took me to impart to him this power? Why something less than
8 hours, and that was in snatches of five minutes at a time; his next brother a
boy of 6 has had a phonetic education, what is the consequence? Reading in
the first stage was so delightful that he taught himself to read. My eldest boy
11 years old, at a first-rate school has carried off the prize for orthography».
Mr. Ellis, who did so much for education writes, «With the phonetic system the
Primer is mastered within 3 months at most; careful experiments have
established 1) that pupils may be taught to read books in phonetic print in
from 10 to 40 hours, and that when they have attained fluency in reading
ordinary print, the pronunciation is much improved, the interest in study kept
alive, and a logical training of enduring value given ... and they acquire the art
of ordinary spelling more readily than those instructed on the old method.»»
Let those who think I exaggerate, look into Miss Soames’s introduction to
Phonetics, and they will marvel how a foreigner can ever learn to read and
write English—she gives the 34 ways in which we write the indefinite ‘a’ sound
in aloud—the 26 for representing ‘or’; the 18 for giving ‘sh’ the 20 representing
‘n’, 18 for ‘k’, and so on—Pagliardini enumerates the 44 ways in which ‘oo’ is
written and 36 for the sound ‘ee’; those who have tried to teach foreigners
know how hopeless it all seems.
Pagliardini tells of a work published 1861 on French spelling, which gives
163 ingenious rules and occupies 285 pages. It is asserted that 2 lessons a
week for 3 years will suffice. How much better writes Pagliardini would these
precious hours be spent in studying noble thoughts in books, the history of
nations, the mathematical sciences, or the laws by which God governs the
universe, or if confined to words, then how much more interesting and
intellectual would be their decomposition into their elements, showing their
affinity with words in other languages. What a fund of poetry might be found
in the metaphors of which words are the abbreviated forms. All this, now
unopened to his view for lack of time, would be revealed.
This may be paralleled by the spelling book of the Meiklejohn series.
‘Spelling with sidelights from history.’ It contains 150 pages, gives many rules,
and concludes with one thousand of the most difficult words selected from
examination papers.
M. Pitman has done good service in printing and circulating for a very small
sum various tracts, and I hope my readers will get some, specially the paper
by Prof. Max Müller. Alas, reforms are slow when the opinion of many
unthinking persons has to be formed, before they can be carried. It needed a
pope to reform the calendar.
The Westminster Review for Sept. 1897 has an article on spelling reform,
urging its great importance, if English is to be a world-wide language. The
impossibility of getting a new alphabet adopted at least for a long time is
urged as a reason for pressing minor reforms, the chief being the omission of
all useless letters. Thus we should leve out awl thos perplexing vowels in lev
recev decev belev; and thes changes mit posibly be carid with sum slit efort at
wuns, if sum popular orthor wood requir his book too be printed foneticaly.
Some defend our spelling for philological reasons, but it is unanimously
condemned by philologists; I name those best known in England—Professor
Max Müller pronounces it a national misfortune, and has written an article
against it—Professor Sayce and Skeat, Ellis and Sweet, Dr Murray, editor of the
Etymological Dictionary, condemn it, and amongst linguists, Pagliardini, and
scientists, Dr Gladstone.
But the chief reason, that we should press forward this movement is, that
only thus does it seem possible to avert the catastrophe foreshadowed in an
article on the Queen’s English in the Review of Reviews for June 1897.
Dialectic varieties are arising in the English-speaking Colonies, which, if
unchecked by phonetic symbols corresponding with speech, will develop into
different languages. The longer we delay, the greater will be the difficulty of
agreeing on a common notation—at present the differences of opinion
between us and our colonies, and even between us and our American cousins
are slight, but those who have heard the English of the States spoken by the
children of German immigrants, will recognise the danger.
Miss Soames before her death published reading books in phonetic type,
and spent much time and money in promoting the teaching of English reading
on this system, and in introducing to the notice of English people the alphabet
of the Association Phonétique Internationale, 11, Rue de Fontenay, Bourg la
Reine (Seine).
Such an alphabet would be better than one suitable for English only, but if
Pitman’s is the only one generally available, it is better to use that for
elementary schools, and remember the maxim ‘le mieux est l’ennemi du
bien’—For teaching the right pronunciation of foreign languages, le Maître
Phonétique is very valuable.
Melville Bell’s Visible Speech is a physiological alphabet of marvellous
ingenuity—but perhaps too elaborate for general use, and the conclusions at
which he arrives are not always endorsed by the chief authorities. All students
of phonetics will learn much from reading it.—English visible speech, in 12
lessons 50 cents, Volta bureau Washington, gives the essentials of the system
—the large work costs 4 dollars.
Great efforts are being made in France to introduce an international
phonetic alphabet.
If all could agree on one alphabet, it would be possible for a foreigner to
read at sight any foreign language. It is true there would be certain niceties of
pronunciation to be taught Viva Voce, but the pronunciation would be very
nearly correct at once.
I subjoin a few specimens of writing and the alphabet from ‘lə mɛːtr fɔnetik’
(Le Maître Phonétique).
The French alphabet is very simple. The consonants are as in English except
- ɲ for the palatal n as in signe.
ʃ for ch as in champ—Ex. shut.
ʒ for ʒʰ as in je—Ex. pleasure.
COMPLETE ALPHABET
C- Plosives ʔ qG kg cɟ td pb
O
Nasales ŋ̊ ŋ̌ ɲ̊ ɲ̌ n̥ n̬ m̥ m̬
N
S
Latérales ɫ̥ ɫ̬ ʎ̥ ʎ̬ ɭ̥ ɭ̬
O
N Roulées Q̥ Q̬ R̥ R̬ r r̬
N
E fv Fʋ
Fricatives h H h̬ ʁ̥ ᴚ̬ (ʍ w) x g (ɥ̊ ɥ̌ ) ɕ j ɹ̥ ɹ̬ , θ ð, ʃ ʒ, s z
ʍw ɥ̊ ɥ
S
V Fermées u ɯ ü ï y i (u ü y)
O
Y Mi-
o v ö ë ø e (o ö ø)
fermées
E
-
L Mi-
ɔ ʌ ɔ̈ ä œ ɛ (ɔ ɔ̈ œ)
L ouvertes
E
S Ouvertes ɑ a
Girls,
Knowledge is now no more a fountain seal’d;
Drink deep, until the habits of the slave,
The sins of emptiness, gossip and spite
And slander, die.
The Princess.
In teaching history our aim should be not to miss the “spirit” of the
Introductory.
period we are taking. We have to inquire what forces are at work
moulding the character of the nation, and to estimate the results they
produce. We have to find the place our period holds in building up the national history.
Each period has a heritage from the past, each hands on its legacy for the future—of
warning from failure or from a success which is more disastrous than failure—of
encouragement from victories, not necessarily of the battlefield, and which perhaps
were won at the cost of noble lives willingly, even joyfully, offered.
There have been periods of ignoble wars, such as the Hundred Years’ War, when
Englishmen were brutalised by murder and rapine, ruining a people too deeply sunk in
misery to defend themselves. And retribution overtook the nation as it overtakes the
individual. Our own Wars of the Roses were the fruit of the unjust wars in France.
There have been periods of ignoble peace, when “peace with dishonour” might have
been England’s motto, when foreign troops were subsidised to protect the shores that
Englishmen were too craven-hearted to defend themselves, when enthusiasm was
ridiculed as “mock patriotism,” and political reformers were nicknamed “boy patriots”.
Corruption was reduced to a system, and Walpole believed that every man had his
price. The Church was paralysed by spiritual deadness.
Individual men stand out as warnings or examples. Richard II. appears first as full of
noble impulses, a born leader of men, but his crime determines his life. To rid himself
of the man who knows his crime, he banishes Norfolk for life; the other, who suspects
it, he banishes for a term of years, and this is reduced at the intercession of old Gaunt.
Either the punishment was, or was not, just. If just, it ought not to have been reduced
on petition; if unjust, it ought never to have been inflicted. Henceforward Richard
rapidly deteriorates: he seizes Gaunt’s lands in spite of his promise to the absent
Bolingbroke, in spite of the warning of his uncle York:—
Take Hereford’s rights away and take from Time
His charters and his customary rights...
You pluck a thousand dangers on your head,
You lose a thousand well-disposed hearts,
And prick my tender conscience to those thoughts
Which honour and allegiance cannot think.
Richard has himself set the example of disregard of others’ rights, and makes it
possible for Bolingbroke to return in the name of justice and raise the country against
the king.
The teacher of history in the older classes ought to be able to
Previous knowledge.
assume a correct knowledge of the most important facts and dates
at least in English history. These are very easily learnt in childhood
and most difficult to acquire by older girls. Those who have been trained on the
historical chart are acquainted with the main characteristic of each century, and the
principal events in it, and have no difficulty in grouping fresh knowledge round central
well-known facts, just as the geographical student can fill in with increasing
completeness a map from memory. Comparatively few are trained in any knowledge of
foreign history, and I have known not a few grown-up girls find the greatest difficulty
in mastering the leading names and events in French and other European history. In
this respect other nations are beyond us. Foreign girls, both French and German, are
trained to connect the history of their own country with the general course of events,
and know the facts of European history as a whole. The absence of this knowledge in
English girls makes the study of foreign policy unnecessarily difficult to them.
In outline history, paint with a thick brush. “One can’t see the
Continuity of history.
wood for the trees in it” might too often be the criticism of the
pupil on a lesson. The conscientious teacher tries to omit nothing,
the consequence in the pupil’s mind is blind confusion. The principle of selection rules
here if anywhere. We must aim at avoiding the defect which Lord Acton denounces as
“the want of an energetic understanding of the sequence and real significance of
events, which ... is ruin to a student of history. It is playing at study (he continues) to
see nothing but the unmeaning and unsuggestive surface as we generally do.” We
want instead to trace in broad outline the continuity of history—for instance, look at
the Wars of the Roses in this light. How do they stand in relation to constitutional
development? While the nobles were at war, the commons were gaining victories,
bloodless it is true, but more lasting than any gained on battlefields. It was a time of
immense constitutional development. And yet these victories were practically worthless
for the moment. What advantage was it to the victim of the “overmighty subject” that
the Statute Book provided for his rights and liberties? The “Paston Letters” give a vivid
picture of the impotence of the ordinary subject to get the law enforced. What the
country needed was strong government, not political privileges. “Constitutional
development had outrun administrative order,” had outrun, that is to say, the general
point of development reached by the nation at large, and the Tudors came in, so to
speak, on the programme of strong government. The Tudor rule represented the two
great principles of orderly administration and even-handed government. It needed a
dictatorship to accomplish the task. The task was completed at the Armada, and the
country took back the trust at the accession of the Stuarts. That the Stuarts failed to
recognise this, was the cause of the long constitutional struggle that culminated in the
Civil War. Once more constitutional development proceeds, but now the nation is
keeping pace with it.
The subject of sectional as opposed to chronological
Topical or sectional arrangement.
teaching seems to belong here, for upon it depends the
very essence of clearness in teaching. If pupils have
before them the time-map, or chronological chart, already referred to, the teacher can
with greater freedom treat the subjects sectionally, for before the eye of the pupil are
grouped all the parallel events in each square representing some definite space of
time. To teach chronologically may seem more accurate perhaps, but really too often
produces hopeless confusion in the mind of the pupil—the thread is lost in taking up
many different subjects, e.g., in Elizabeth’s reign, I would take as separate sections
her relations with Scotland, necessitating a review of Scotch affairs generally, and the
series of plots for releasing Queen Mary; Elizabeth’s policy with regard to (a) the
Anglican Church; (b) Roman Catholics; (c) Protestant Nonconformists; her Irish policy;
her foreign policy illustrated by her “courtships”; the domestic history of the reign and
so on. The different sections touch sometimes, but it only adds to the interest to
illustrate the new section from one already known. So in the Seven Years’ War, I would
not follow the course of events for each separate year on the Continent and in America
and in India, but I would take the whole course of the war in Europe, explaining why it
was not only justifiable but a stroke of genius in Pitt, to do what he had himself
denounced in the “Hanover-troop minister,” and by utilising foreign troops for
England’s war on the Continent, set her free to follow her true interests in the
colonies, and I would trace as separate sections the laying of the foundations of her
world-empire in India and in Canada.
This method of teaching presupposes that a scheme has been
Syllabus of lessons.
drawn out for the course. If possible the scheme should be given to
the class in the form of a syllabus of the lessons. If printing is too
expensive, it is worth while to cyclostyle copies oneself. The value the class attaches to
them is sufficient reward for the trouble, and they become a model to the girls on
which to arrange their own study of history in post-school days. Examples of such a
syllabus for English history and French history lessons will be found at the end of the
paper.
The historical map ought to be the inseparable
Illustrations: (a) Historical atlas.
accompaniment of the history lesson, and in this respect
there is nearly everything to be wished for. Good wall
maps with bold colouring in which the outlines of different territories can be seen from
a distance, and in which the names are clearly printed in English, have yet to be
found. To use a modern map in doing French outlines or other continental history is
most misleading, and yet too often this is all the teacher has at hand. There is Sprüner
of course, but even if the school can afford these expensive maps, they are not very
satisfactory for the ordinary class; the colouring is not distinct, and the map is so
overcrowded with names that it is difficult to find at a glance the places one wants.
They are rather for private and minute study than for class work. The publisher’s
explanation is that there is not a sufficient demand to make it worth while to bring out
historical maps, an incidental illustration of how little attention is given in English
schools to continental history, while a class map of the Roman Empire can be found
everywhere. At present the teacher is forced to make her own maps. If she is happy
enough to have old pupils with a talent for map-drawing, she can gradually make a
collection of maps enlarged from those in good histories; the maps in Kitchin’s History
of France are invaluable for this purpose, but Kitchin provides nothing for the periods
of the Italian expeditions, and these have to be adapted from Sprüner.
Gardiner’s Student’s Atlas provides what is necessary for the pupil in the English
history class; there is a small cheap German atlas for general history (Putzger, 2
marks), but it is not very satisfactory for the ordinary English schoolgirl, the difference
in the names is puzzling. What is wanted is a student’s atlas for continental, especially
French history, at a reasonable price.
But even given the atlas, it remains for the teacher to find an unfailing receipt by
which to ensure its use.
Not the least part of the value of a syllabus in the hands of a pupil, is
(b) Blackboard
the saving of time it makes in the lesson, otherwise the blackboard
must be used for unfamiliar names and words. The merest glance
through a pupil’s rough notes of French history will be a sufficient proof of this.
Besides the text-book, which every pupil
(c) First-hand acquaintance with
should possess, no teacher of older girls will be authorities.
satisfied unless they read at least passages from
the authorities on the period. The difficulty is to provide a sufficient number of copies
for a large class, or any copies at all, beyond those possessed by the teacher or the
school: this difficulty, however, may be met. There are always girls who are glad to
have good books suggested for Christmas or birthday presents, and who begin a really
nice library of their own in this way. But a class-library can be formed without much
trouble. The nucleus of a class-library being made by the necessary books for one
year’s work, the girls can be asked to leave a similar legacy for their successors. A list
of books wanted, with their prices, can be prepared, and it will be found that several
will combine to give really expensive books, and in this way the class can command
the use of sets of Stubbs, Froude, Gardiner, Ranke, Lecky, etc., besides smaller books
like the Great Statesmen Series.
Since it is impossible for girls with their limited time to read the whole of the big
histories, the teacher will find it a valuable practice to dictate the numbers of the
pages (in one or more volumes) bearing upon her lesson, which the girls should read.
They are thus trained to use authorities, and this is being recognised more and more
as of the first importance. There was a time when girls depended entirely upon their
notes, and the misspelling of names of historians showed that their knowledge of
great writers was second-hand. But when they get a first-hand acquaintance with
historians like Froude, Gardiner, Seeley, Ranke, Lecky, they are insensibly being trained
to be satisfied with nothing but the best.
The period should be studied by the teacher, and
(d) Contemporary writings: chronicles.
to a certain extent by the pupil, in contemporary
writers. Chronicles are delightful reading. Who that
has once learnt to know Saint Louis of France in the pages of his faithful seneschal,
can fail to breathe the very atmosphere of the time? De Joinville shows him what a
later preacher called him, “the most loyal spirit of his age”. Again no weighty
dissertations on the small account in which human life was held in the Middle Ages
would be so convincing as the incidental contemptuous remarks of the courtier-
chronicler Froissart. The exquisite courtesy to a De Ribeaumont was quite compatible
with the halters for the six citizens of Calais. And to take one more illustration quite
late on in the centuries—what a gulf separates ante-Reform times from our own! How
expressive of the haughty landed aristocrat are these words of the Duchess of
Buckingham after condescending to listen to the Wesleyan preaching: “I thank your
ladyship for the information concerning the Methodist preachers. Their doctrines are
most repulsive and strongly tinctured with impertinence and disrespect towards their
superiors, in perpetually endeavouring to level all ranks and to do away with all
distinctions. It is monstrous to be told that you have a heart as sinful as the common
wretches that crawl the earth. This is highly offensive, and I cannot but wonder that
your ladyship should relish any sentiments so much at variance with high birth and
good breeding.”
Full lists of contemporary writers will be found in Traill’s volumes on Social England,
which as “a record of the progress of the people in Religion, Laws, Learning, Arts,
Industry, Commerce, Science, Literature and Manners, from the earliest times to the
present day,” meets perhaps the greatest want of the ordinary teacher, to whom no
one general history of social progress was before accessible.
As illustrations there are also historical portraits, contemporary
(e) Historical pictures.
pictures of historic scenes, and pictures of costumes. Most
schools now subscribe to the “Art for Schools Association,” and
can make a very good portrait gallery of their own. The splendid collection of historical
costumes designed by Mr. Lewis Wingfield for the Healtheries can still be seen, I
believe, and a few of them have been reproduced by him in a book with descriptive
letterpress. Exhibitions, like the Tudor and Stuart, are most valuable to the realisation
of history, and visits to historical buildings are within the possibilities of most, and add
great zest to many a holiday both for teachers and girls. It is impossible to forget the
circumstances of the Dauphin’s coronation at Rheims, after staying where Joan of Arc
stayed and standing in the cathedral, where she witnessed the fulfilment of her
mission.
Passages from historical poems or from a
(f) Historical poems, Shakspere’s plays,
Shakspere play often add to the interest of a historical novels.
lesson; as the challenge-scene from Richard II.,
the trial-scene from Henry VIII., Milton’s sonnet on the massacre in Piedmont,
Spenser’s Gloriana and the false Duessa for Elizabeth and Mary Queen of Scots. And in
quite modern history Mrs. Hamilton King’s Disciples, Swinburne’s Songs before Sunrise,
Mrs. Browning’s Peace of Villafranca, all give expression to the passionate longing for
freedom of Italy.
Perhaps nothing makes history more real than a good historical novel. Bulwer-
Lytton’s Last of the Barons makes the figure of Warwick as lifelike as that of any
minister of our own day. Edward IV., Clarence, Richard III. have each their
individuality, and so has that shadowy prince who was killed at Tewkesbury, while
Isabella Neville stands out for ever distinct from her gentle, timid sister Anne.
John Inglesant gives the very spirit of the Charles I. period—cavaliers and ladies
coquetting with the classics in the learned Oxford halls, the devotion, even to the
death, of the Jesuit-trained John Inglesant, and the midnight apparition of the
murdered Strafford to the king, for whom he had laid down his life.
It is quite worth while to put up a list of historical novels bearing on their period, for
older as well as for younger classes.
How are we to test the work done by the pupils? Lord
Home-work: (a) Viva-voces.
Acton quotes from Sir W. Hamilton: “I must regard the main
duty of a professor to consist, not simply in communicating
information, but in doing this in such a manner and with such an accompaniment of
subsidiary means, that the information he conveys may be the occasion of awakening
his pupils to a vigorous and varied exertion of their faculties”.
By means of viva-voce questions and paper work, the class should be tested
between each lecture. The object of the teacher is to find out with as little expenditure
of time as possible, that the work set has been thoroughly done. I know no better
means of doing this than by what are called written viva-voces. The teacher prepares
two sets of questions called respectively A and B. The alternate girls write the answers
to the A and B questions in small exercise books which they keep for the purpose.
They rule two margins, the left-hand for the number of the question, the right-hand
margin is used by the corrector. Ten minutes can test an hour’s lesson. The books are
changed so that the Bs correct the work of the As, and have to attend to the answers
of the questions they did not do. The teacher repeats aloud the answer to each
question. Each corrector signs her name and puts the mark obtained. The teacher,
when she looks through the books afterwards, can thus bring home any careless
correction to the right person, and anything like favouritism in correcting is prevented.
This viva-voce work ensures accurate knowledge of facts, and I have known girls find
it sufficiently useful, to continue the same system among themselves after they have
gone up to the university.
The most valuable exercise for the pupil is the writing of essays.
(b) Essay-writing.
These may begin on a subject already dealt with in class (care being
taken that the essay is not a reproduction of notes of the lesson),
but the pupil will soon be trained to read and think out for herself subjects which she
has not previously heard discussed. She will learn experimentally what Lord Acton
calls, “those shining precepts which are the registered property of every school, that is
to say, learn as much by writing as by reading; be not content with the best books,
seek sidelights from the others; have no favourites; keep men and things apart; guard
against the prestige of great names; see that your judgments are your own and do not
shrink from disagreement; no trusting without testing; be more severe to ideas than to
actions; do not overlook the strength of the bad cause or the weakness of the good”.
The giving back of the essays ought to be a very valuable lesson. Happy passages
should be read aloud, weak passages criticised, each paper estimated as a whole, and
the pupil ought to leave the class, feeling that if the work were to be done again, she
at least understands the general drift of the subject and could treat it more adequately
than before.
I venture to illustrate my meaning, the subject set being a discussion of the policy of
Francis I. in his relations with Charles V. The essay should show that Francis I., like his
predecessors in the Italian expeditions, Charles VIII. and Louis XII., failed to realise in