•
TableofContents
C++NetworkProgramming,Volume2:
SystematicReusewithACEandFrameworks
ByDouglasC.Schmidt,StephenD.Huston
Publisher
:AddisonWesley
PubDate
:October29,2002
ISBN
:0-201-79525-6
Pages
:384
Doyouneedtodevelopflexiblesoftwarethatcanbecustomizedquickly?
Doyouneedtoaddthepowerandefficiencyofframeworkstoyour
software?TheADAPTIVECommunicationEnvironment(ACE)isan
open-sourcetoolkitforbuildinghigh-performancenetworkedapplications
andnext-generationmiddleware.ACE'spowerandflexibilityarisefrom
object-orientedframeworks,usedtoachievethesystematicreuseof
networkedapplicationsoftware.ACEframeworkshandlecommon
networkprogrammingtasksandcanbecustomizedusingC++language
featurestoproducecompletedistributedapplications.
C++NetworkProgramming,Volume2,focusesonACEframeworks,
providingthoroughcoverageoftheconcepts,patterns,andusagerules
thatformtheirstructure.Thisbookisapracticalguidetodesigning
object-orientedframeworksandshowsdevelopershowtoapply
frameworkstoconcurrentnetworkedapplications.C++Networking,
Volume1,introducedACEandthewrapperfacades,whicharebasic
networkcomputingingredients.Volume2explainshowframeworksbuild
onwrapperfacadestoprovidehigher-levelcommunicationservices.
WrittenbytwoexpertsintheACEcommunity,thisbookcontains:
AnoverviewofACEframeworks
Designdimensionsfornetworkedservices
DescriptionsofthekeycapabilitiesofthemostimportantACE
frameworks
NumerousC++codeexamplesthatdemonstratehowtouseACE
frameworks
C++NetworkProgramming,Volume2,teacheshowtouseframeworks
towritenetworkedapplicationsquickly,reducingdevelopmenteffortand
overhead.ItwillbeaninvaluableassettoanyC++developerworkingon
networkedapplications.
•
TableofContents
C++NetworkProgramming,Volume2:
SystematicReusewithACEandFrameworks
By
DouglasC.Schmidt,StephenD.Huston
Publisher
:AddisonWesley
PubDate
:October29,2002
ISBN
:0-201-79525-6
Pages
:384
Copyright
Foreword
AboutThisBook
IntendedAudience
StructureandContent
RelatedMaterial
Acknowledgments
Chapter1.
Object-OrientedFrameworksforNetworkProgramming
Section1.1.
AnOverviewofObject-OrientedFrameworks
Section1.2.
ComparingSoftwareDevelopmentandReuseTechniques
Section1.3.
ApplyingFrameworkstoNetworkProgramming
Section1.4.
ATourthroughtheACEFrameworks
Section1.5.
Example:ANetworkedLoggingService
Section1.6.
Summary
Chapter2.
ServiceandConfigurationDesignDimensions
Section2.1.
ServiceandServerDesignDimensions
Section2.2.
ConfigurationDesignDimensions
Section2.3.
Summary
Chapter3.
TheACEReactorFramework
Section3.1.
Overview
Section3.2.
TheACE_Time_ValueClass
Section3.3.
TheACE_Event_HandlerClass
Section3.4.
TheACETimerQueueClasses
Section3.5.
TheACE_ReactorClass
Section3.6.
Summary
Chapter4.
ACEReactorImplementations
Section4.1.
Overview
Section4.2.
TheACE_Select_ReactorClass
Section4.3.
TheACE_TP_ReactorClass
Section4.4.
TheACE_WFMO_ReactorClass
Section4.5.
Summary
Chapter5.
TheACEServiceConfiguratorFramework
Section5.1.
Overview
Section5.2.
TheACE_Service_ObjectClass
Section5.3.
TheACE_Service_RepositoryClasses
Section5.4.
TheACE_Service_ConfigClass
Section5.5.
Summary
Chapter6.
TheACETaskFramework
Section6.1.
Overview
Section6.2.
TheACE_Message_QueueClass
Section6.3.
TheACE_Task_Class
Section6.4.
Summary
Chapter7.
TheACEAcceptor-ConnectorFramework
Section7.1.
Overview
Section7.2.
TheACE_Svc_HandlerClass
Section7.3.
TheACE_AcceptorClass
Section7.4.
TheACE_ConnectorClass
Section7.5.
Summary
Chapter8.
TheACEProactorFramework
Section8.1.
Overview
Section8.2.
TheAsynchronousI/OFactoryClasses
Section8.3.
TheACE_HandlerClass
Section8.4.
TheProactiveAcceptor-ConnectorClasses
Section8.5.
TheACE_ProactorClass
Section8.6.
Summary
Chapter9.
TheACEStreamsFramework
Section9.1.
Overview
Section9.2.
TheACE_ModuleClass
Section9.3.
TheACE_StreamClass
Section9.4.
Summary
Glossary
Bibliography
Copyright
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Wherethose
designationsappearinthisbook,andAddison-Wesleywasawareofa
trademarkclaim,thedesignationshavebeenprintedwithinitialcapital
lettersorinallcapitals.
Theauthorsandpublisherhavetakencareinthepreparationofthis
book,butmakenoexpressedorimpliedwarrantyofanykindand
assumenoresponsibilityforerrorsoromissions.Noliabilityisassumed
forincidentalorconsequentialdamagesinconnectionwithorarisingout
oftheuseoftheinformationorprogramscontainedherein.
Thepublisheroffersdiscountsonthisbookwhenorderedinquantityfor
bulkpurchasesandspecialsales.Formoreinformation,pleasecontact:
U.S.CorporateandGovernmentSales(800)382-3419
ForsalesoutsideoftheU.S.,pleasecontact:InternationalSales
(317)581-3793
VisitAddison-WesleyontheWeb:www.awprofessional.com
LibraryofCongressCataloging-in-PublicationDataSchmidt,DouglasC.
C++networkprogramming/DouglasC.Schmidt,StephenD.Huston.
p.cm.
Includesbibliographicalreferencesandindex.
Contents:Vol.2.SystematicreusewithACEandframeworks.
(v.2:pbk.)
1.C++(Computerprogramlanguage)2.Object-orientedprogramming
(Computerscience)3.Computernetworks.I.Huston,StephenD.II.Title.
QA76.73.C153S3682002
005.2'762—dc21
2001053345
Copyright©2003byPearsonEducation,Inc.
Allrightsreserved.Nopartofthispublicationmaybereproduced,stored
inaretrievalsystem,ortransmitted,inanyform,orbyanymeans,
electronic,mechanical,photocopying,recording,orotherwise,withoutthe
priorconsentofthepublisher.PrintedintheUnitedStatesofAmerica.
PublishedsimultaneouslyinCanada.
Forinformationonobtainingpermissionforuseofmaterialfromthis
work,pleasesubmitawrittenrequestto:PearsonEducation,Inc.
RightsandContractsDepartment75ArlingtonStreet,Suite300
Boston,MA02116
Fax:(617)848-7047
Textprintedonrecycledpaper12345678910—MA—0605040302
Firstprinting,October2002
Foreword
TheADAPTIVECommunicationEnvironment(ACE)toolkithasachieved
enormoussuccessintheareaofmiddlewarefornetworkedcomputing.
Duetoitsflexibility,performance,platformcoverage,andotherkey
properties,ACEenjoysbroadacceptancebythenetworkedapplication
softwarecommunity,asevidencedbyitsuseinthousandsof
applications,inscoresofcountries,andindozensofdomains.ACEhas
alsoreceivedconsiderableattentionbeyondthemiddlewarecommunity
sinceit'sanopen-sourcerolemodelforhigh-qualityandwell-designed
pattern-orientedsoftwarearchitectures.
ButwhyisACEsosuccessful?Addressingthisquestionproperlytakes
somethought.Tostartoff,let'sreconsidertheForewordfromC++
NetworkProgramming:MasteringComplexitywithACEandPatterns
(C++NPv1)andresumethemasstransitanalogypresentedtherebymy
colleagueSteveVinoski.Steve'srightthatahigh-qualitymasstransit
systemconsistsofmorethanjustaircraft,airports,trains,trainstations,
andrails.Italsoneedslessobviousinfrastructure,suchasscheduling,
routing,ticketing,maintenance,andmonitoring.Butevenacomplete
collectionofingredientsisstillnotsufficienttodevelopaneffectivemass
transitsystem.Arrangingtheseingredientssotheyseamlesslyfulfilltheir
primaryobjective—fastandreliabletransportationofpeople—isequally
important.Wouldyouuseamasstransitsystemwhoseticketingwas
locatedinatrainmaintenancelocationoranairporthangar,orwhose
plannedandactualschedulingandroutingweren'tavailabletothe
public?Idoubtit!
Thesuccessofmasstransitsystemsdependsonmorethanthe
knowledgeoftheinfrastructurepartsthatareprovided—itdependson
howthesedifferentpartsmustbeconnectedandintegratedwiththeir
environment.Thisknowledgeenablesarchitectsofmasstransitsystems
tointegrateindividualpartsintohigher-levelbuildingblocksandto
connectthesebuildingblockseffectively.Forexample,ticketing,
informationpoints,baggageoffices,andboardingareintegratedintrain
stationslocatedatcitycentersormajorsuburbancenters.Likewise,
airportsareoftenlocatednearlargecitiesandconnectedbyfrequent
expresstrains.
Evenmasstransitcentersthemselvesarearrangedsothatactivitiescan
beperformedeffectively.Forexample,whenyouenteratrainstationor
airportviathemainentrance,youfindticketagents,informationcenters,
andtimetables.Youalsofindshopstosatisfyyourtravelneeds.Asyou
enterthemaintrainhallorairportconcourse,youfindotherinformation
centers,up-to-dateschedulinginformation,andtheplatformsandgates
forboardingthetrainsandplanes.Masstransitcentersthusnotonly
provideallnecessaryservicestobeginandendajourney,theyalso
organizetheirinternal"controlflows"effectively.Whilethecorestructures
andcontrolflowsinmosttrainstationsandairportsaresimilar,their
concreterealizationcandifferwidely.Yetweallrecognizethesemass
transitcenterpatternsimmediatelysincetheyfollowkeyinvariantsthat
we'velearnedthroughyearsofexperience.
Sowhat'stheconnectionbetweensuccessfulmasstransitsystemdesign
andthesuccessofACE?Theanswerissimple:Inadditiontothebasic
networkcomputingingredients(thewrapperfacadesthatDougand
SteveintroducedinC++NPv1),ACEalsoincludesusefulobject-oriented
frameworksthatbuilduponthesewrapperfacadesandprovideuseful
higher-levelcommunicationservices,suchaseventdemultiplexingand
dispatching,connectionmanagement,serviceconfiguration,concurrency,
andhierarchicallylayeredstreamprocessing.TheACEframework
servicessatisfymanynetworkedsoftwareneedsbyorganizingthe
structuresandinternalcontrolflowsofyourapplicationseffectivelyvia
keypatternslearnedthroughyearsofexperience.
TheACEframeworksofferyouanumberofimportantbenefits:
Youneedn'tdevelopthecapabilitiesprovidedbyACE,whichwill
saveconsiderabletimeandeffort.Youcanthereforefocusonyour
keyresponsibility:implementingtheapplicationfunctionalityrequired
byyourcustomersandendusers.
TheACEframeworksreifytheextensivenetworkprogramming
expertisethatDoug,Steve,andtheircolleagueshavegainedover
severaldecades.Inparticular,theACEframeworksefficiently
implementthecanonicalclasses,classrelationships,andcontrol
flowscommontonetworkedapplications.TheACEframeworksare
testedregularlybythousandsofusersfromaroundtheworld,which
hasyieldedmanyusefulcorrectionsandimprovements.AsanACE
user,youcandirectlyleveragethecorrectness,effectiveness,and
efficiencyoftheACEframeworksinyourapplications.
Aframeworkisn'taframeworkifitcan'tbeadaptedtospecificuser
needs.ThismeansyoucanadapttheACEframeworksatkeypoints
ofvariationinnetworkedapplications.Forexample,theACE
Reactorframeworkcanbeadaptedtousedifferentevent
demultiplexerfunctions,suchasWaitForMultipleObjects()
orselect().Likewise,theACEAcceptor-Connectorframework
canbeconfiguredwithdifferentIPCmechanisms.Whilethis
adaptabilityisbeneficialbyitself,ACEgoesastepfurther:formany
adaptationsyoucanconfigurethedesiredstrategiesfromavailable
andinterchangeableimplementations.InadditiontothedifferentReactorimplementationsmentionedabove,forinstance,ACEprovides
wrapperfacadesforvariousIPCmechanisms,suchastheSockets,
SSL,TLI,andsharedmemory,thathelptoconfiguretheACE
Acceptor-Connectorframeworkforspecificplatformsand
applications.
Lastbutnotleast,theACEframeworksdon'texistinisolation.You
canthereforecombinetheminnovelwaystocreatenetworked
applicationsandentirelynewtypesofmiddleware.Forexample,you
canintegratetheReactorframeworkwiththeAcceptor-Connector
frameworktoseparateconnectionestablishmentfromservice
processingfunctionalityinevent-drivenapplications.Youcan
likewiseintroducevariousformsofconcurrencyintoyour
applicationsusingtheACETaskframework.
Asaresultofadvisingandleadingmanysoftwareprojectsoverthe
years,I'vefoundthatACEgreatlysimplifiesthetaskofemploying
reusablemiddlewarethatcanbecustomizedreadilytomeettheneedsof
networkedapplications.Notallnetworkedapplicationsneedheavyweight
middleware,suchasapplicationservers,webservices,andcomplex
componentmodels.Yetmostnetworkedapplicationscanbenefitfrom
portableandefficienthostinfrastructuremiddlewarelikeACE.This
flexibilityisthecoreofACE'ssuccesssinceyouneedn'tcommittoan
entiremiddlewaresuiteifyoudon'tuseallofit.Instead,youcancombine
justtheessentialACEmiddlewareclassesyouneedtocompose
applicationsthataresmall,butaspowerfulasnecessary.Forthisreason,
IpredictthatACEwillstillbewidelyusedlongaftertheinfluenceof
today'sheavyweightmiddlewarehaswaned.
ACE'stremendousflexibilityalsoneedn'tleadtoaseaofincompatible
middlewareimplementations.Forexample,ifyoubuildanembedded
systemthatspeakstheCORBAInternetinter-ORBprotocol(IIOP)tothe
outsideworld,youcanuseTheACEORB(TAO),whichisaCORBAcompliant,open-source,real-timeobjectrequestbroker(ORB)builtusing
theACEwrapperfacadesandframeworks.IfCORBAisoverkillforyour
applicationneeds,however,youcanbuildcustom,yetinteroperable,
middlewareusingtheappropriateACEclasses.Bothsolutionscanbe
basedonthesamecorestructuresandprotocols,suchastheACE
CommonDataRepresentation(CDR)classesanditsTCP/IPSocket
wrapperfacades.Theycanthereforecommunicateseamlesslywithone
another,justasyoucantakeatrainfromParistoIstanbul—thefamous
OrientExpress—andtravelthroughmanyEuropeancountrieswithout
havingtochangetrainsduetoincompatiblerailroadnetworks.
AsSteveVinoskiandIhavepointedout,therearemanysimilarities
betweenhigh-qualitymasstransitsystemsandhigh-qualitynetworking
middleware.TomeandthousandsofotherC++developersaroundthe
world,ACEisthetoolkitforbuildingthelatter!Aftersayingsomanygood
thingsaboutACE,however,let'sreturntothemainintentofthis
foreword:introducingthesecondvolume(C++NPv2)oftheC++Network
Programmingseries.Aswithallsoftwaretechnologiesandmiddleware,
themoreyouunderstandyourtools,thebetteryou'llbeabletoapply
them.ItturnsoutthatusingACEinyourapplicationsisjustoneaspectof
improvingyournetworkedsoftware.TobenefitsignificantlyfromACE's
manyadvantages,youthereforealsoneedasoundunderstandingofthe
coreconcepts,patterns,andusagerulesthatunderlieitspowerful
frameworks.
Foryears,acommonwaytolearnACEinvolvedstudyingitscode,
comments,andexampleapplications.Clearly,thisprocesswastime
consuminganderrorprone.Moreover,evenaftermanagingtoreadthe
severalhundredthousandlinesofC++codeinACE,itwaseasytomiss
theforestforthetrees.AstheGreekphilosopherThucydidesnotedtwo
millenniaago:"Amanwhohastheknowledgebutlacksthepowerto
clearlyexpresshimselfisnobetteroffthanifhehadneveranyideaat
all."
We'rethereforefortunatethatDougandStevefoundtimeintheirbusy
schedulestocreatesuchahigh-qualitybookontheACEframeworks.
C++NPv2explainstheideasandconceptsunderlyingtheACE
frameworksinaneasilyaccessibleformusingthepopularconcurrency
andnetworkingpatternsfromthePOSA[POSA1,POSA2]and"Gangof
Four"[GoF]patternsbooks.Thesepatterns,inturn,reifythoughtfuland
time-provensolutionstocommonnetworkingproblems.Forexample,
theytellyouwhattheproblemsare,whytheseproblemsarehard,what
thesolutionstotheseproblemsare,andwhythesesolutionsappliedto
ACEareofhighquality.Ifyouwantthoroughcoverageofthepatterns
andframeworksinACEthatareshapingthenextgenerationof
networkedapplicationsoftwarethenreadthisbook.I'velearnedmuch
fromitandI'msureyouwilltoo.
FrankBuschmann
SeniorPrincipalEngineer
SiemensCorporateTechnology
Munich,Germany
AboutThisBook
Softwarefornetworkedapplicationsmustpossessthefollowingqualities
tobesuccessfulintoday'scompetitive,fast-pacedcomputingindustry:
Affordability,toensurethatthetotalownershipcostsofsoftware
acquisitionandevolutionarenotprohibitivelyhigh
Extensibility,tosupportsuccessionsofquickupdatesandadditions
toaddressnewrequirementsandtakeadvantageofemerging
markets
Flexibility,tosupportagrowingrangeofmultimediadatatypes,
trafficpatterns,andend-to-endqualityofservice(QoS)requirements
Portability,toreducetheeffortrequiredtosupportapplicationson
heterogeneousOSplatformsandcompilers
Predictabilityandefficiency,toprovidelowlatencytodelaysensitivereal-timeapplications,highperformancetobandwidthintensiveapplications,andusabilityoverlow-bandwidthnetworks,
suchaswirelesslinks
Reliability,toensurethatapplicationsarerobust,faulttolerant,and
highlyavailable
Scalability,toenableapplicationstohandlelargenumbersofclients
simultaneously
Writinghigh-qualitynetworkedapplicationsthatexhibitthesequalitiesis
hard—it'sexpensive,complicated,anderrorprone.Thepatterns,C++
languagefeatures,andobject-orienteddesignprinciplespresentedin
C++NetworkProgramming,Volume1:MasteringComplexitywithACE
andPatterns(C++NPv1)helptominimizecomplexityandmistakesin
networkedapplicationsbyrefactoringcommonstructureandfunctionality
intoreusablewrapperfacadeclasslibraries.Thekeybenefitsofreuse
willbelost,however,iflargepartsoftheapplicationsoftwarethatuses
theseclasslibraries—orworse,theclasslibrariesthemselves—mustbe
rewrittenforeachnewproject.
Historically,manynetworkedapplicationsoftwareprojectsbeganby
1. Designingandimplementingdemultiplexinganddispatching
infrastructuremechanismsthathandletimedeventsandI/Oon
multiplesockethandles
Addingserviceinstantiationandprocessingmechanismsatopthe
demultiplexinganddispatchinglayer,alongwithmessagebufferingand
queueingmechanisms
Implementinglargeamountsofapplication-specificcodeusingthisad
hochostinfrastructuremiddleware
Thisdevelopmentprocesshasbeenappliedmanytimesinmany
companies,bymanyprojectsinparallel.Evenworse,it'sbeenappliedby
thesameteamsinaseriesofprojects.Regrettably,thiscontinuous
rediscoveryandreinventionofcoreconceptsandcodehaskeptcosts
unnecessarilyhighthroughoutthesoftwaredevelopmentlifecycle.This
problemisexacerbatedbytheinherentdiversityoftoday'shardware,
operatingsystems,compilers,andcommunicationplatforms,whichkeep
shiftingthefoundationsofnetworkedapplicationsoftwaredevelopment.
Object-orientedframeworks[FJS99b,FJS99a]areoneofthemost
flexibleandpowerfultechniquesthataddresstheproblemsoutlined
above.Aframeworkisareusable,"semi-complete"applicationthatcan
bespecializedtoproducecustomapplications[JF88].Frameworkshelp
toreducethecostandimprovethequalityofnetworkedapplicationsby
reifyingprovensoftwaredesignsandpatternsintoconcretesourcecode.
Byemphasizingtheintegrationandcollaborationofapplication-specific
andapplication-independentclasses,frameworksenablelargerscale
reuseofsoftwarethancanbeachievedbyreusingindividualclassesor
stand-alonefunctions.
Intheearly1990s,DougSchmidtstartedtheopen-sourceACEprojectto
bringthepowerandefficiencyofpatternsandframeworkstonetworked
applicationdevelopment.AswithmuchofDoug'swork,ACEaddressed
manyreal-worldproblemsfacedbyprofessionalsoftwaredevelopers.
Overthefollowingdecade,hisgroupsattheUniversityofCalifornia,
Irvine;WashingtonUniversity,St.Louis;andVanderbiltUniversity,along
withcontributionsfromtheACEusercommunityandSteveHustonat
Riverace,yieldedaC++toolkitcontainingsomeofthemostpowerfuland
widelyusedconcurrentobject-orientednetworkprogrammingframeworks
intheworld.ByapplyingreusablesoftwarepatternsandalightweightOS
portabilitylayer,theframeworksintheACEtoolkitprovidesynchronous
andasynchronouseventprocessing;concurrencyandsynchronization;
connectionmanagement;andserviceconfiguration,initialization,and
hierarchicalintegration.
ThesuccessofACEhasfundamentallyalteredthewaythatnetworked
applicationsandmiddlewarearedesignedandimplementedonthemany
operatingsystemsoutlinedinSidebar2(page16).ACEisbeingusedby
thousandsofdevelopmentteams,rangingfromlargeFortune500
companiestosmallstartupstoadvancedresearchprojectsatuniversities
andindustrylabs.Itsopen-sourcedevelopmentmodelandselfsupportingcultureissimilarinspiritandenthusiasmtothatdrivingLinus
Torvalds'spopularLinuxoperatingsystem.
ThisbookdescribeshowtheACEframeworksaredesignedandhow
theycanhelpdevelopersnavigatebetweenthelimitationsof
1. Low-levelnativeoperatingsystemAPIs,whichareinflexible
andnonportable
High-levelmiddleware,suchasdistributionmiddlewareandcommon
middlewareservices,whichoftenlackstheefficiencyandflexibilityto
supportnetworkedapplicationswithstringentQoSandportability
requirements
Theskillsrequiredtoproduceandusenetworkedapplicationframeworks
havetraditionallybeenlockedintheheadsofexpertdevelopersorburied
deepwithinthesourcecodeofnumerousprojectsthatarespread
throughoutanenterpriseoranindustry.Neitheroftheselocationsis
ideal,ofcourse,sinceit'stimeconsuminganderrorpronetoreengineer
thisknowledgeforeachnewapplicationorproject.Toaddressthis
problem,thisbookillustratesthekeypatterns[POSA2,POSA1,GoF]
thatunderliethestructureandfunctionalityoftheACEframeworks.Our
coverageofthesepatternsalsomakesiteasiertounderstandthedesign,
implementation,andeffectiveuseoftheopen-sourceACEtoolkititself.
IntendedAudience
Thisbookisintendedfor"handson"C++developersoradvanced
studentsinterestedinunderstandinghowtodesignobject-oriented
frameworksandapplythemtodevelopnetworkedapplications.Itbuilds
uponmaterialfromC++NPv1thatshowshowdeveloperscanapply
patternstomastercomplexitiesarisingfromusingnativeOSAPIsto
programnetworkedapplications.It'sthereforeimportanttohaveasolid
graspofthefollowingtopicscoveredinC++NPv1beforereadingthis
book:
Networkedapplicationdesigndimensions,includingthe
alternativecommunicationprotocolsanddatatransfermechanisms
discussedinChapter1ofC++NPv1
Internetprogrammingmechanisms,suchasTCP/IPconnection
managementanddatatransferAPIs[Ste98]discussedinChapter2
ofC++NPv1
Concurrencydesigndimensions,includingtheuseofprocesses
andthreads,iterativeversusconcurrentversusreactiveservers,and
threadingmodels[Ste99]discussedinChapters5through9of
C++NPv1
Synchronizationtechniquesnecessarytocoordinatethe
interactionsofprocessesandthreadsonvariousOSplatforms
[KSS96,Lew95,Ric97]discussedinChapter10ofC++NPv1
Object-orienteddesignandprogrammingtechniques[Boo94,
Mey97]thatcansimplifyOSAPIsandavoidprogrammingmistakes
throughtheuseofpatterns,suchasWrapperFacade[POSA2]and
Proxy[POSA1,GoF]discussedinChapter3andAppendixAof
C++NPv1
TheACEframeworksarehighlyflexibleandpowerful,dueinlargepartto
theiruseofC++languagefeatures[Bja00].Youshouldthereforebe
familiarwithC++classinheritanceandvirtualfunctions(dynamicbinding)
aswellastemplates(parameterizedtypes)andthemechanismsyour
compiler(s)offertoinstantiatethem.ACEprovidesagreatdealof
assistanceinovercomingdifferencesbetweenC++compilers.Asalways,
however,youneedtoknowthecapabilitiesofyourdevelopmenttools
andhowtousethem.Knowingyourtoolsmakesiteasiertofollowthe
sourcecodeexamplesinthisbookandtobuildandrunthemonyour
systems.Finally,asyoureadtheexamplesinthisbook,keepinmindthe
pointsnotedinSidebar7(page46)regardingUMLdiagramsandC++
code.
StructureandContent
OurC++NPv1bookaddressedhowtomastercertaincomplexitiesof
developingnetworkedapplications,focusingontheuseofACE's
wrapperfacadestoavoidproblemswithoperatingsystemAPIswrittenin
C.Thisbook(whichwecallC++NPv2)elevatesourfocustomotivate
anddemystifythepatterns,designtechniques,andC++features
associatedwithdevelopingandusingtheACEframeworks.These
frameworkshelpreducethecostandimprovethequalityofnetworked
applicationsbyreifyingprovensoftwaredesignsandpatternsinto
frameworksthatcanbereusedsystematicallyacrossprojectsand
enterprises.TheACEframeworksexpandreusetechnologyfarbeyond
whatcanbeachievedbyreusingindividualclassesorevenclass
libraries.
ThisbookpresentsnumerousC++applicationstoreinforcethedesign
discussionsbyshowingconcreteexamplesofhowtousetheACE
frameworks.Theseexamplesprovidestep-by-stepguidancethatcan
helpyouapplykeyobject-orientedtechniquesandpatternstoyourown
networkedapplications.Thebookalsoshowshowtoenhanceyour
designskills,focusingonthekeyconceptsandprinciplesthatshapethe
designofsuccessfulobject-orientedframeworksfornetworked
applicationsandmiddleware.
Thechaptersinthebookareorganizedasfollows:
Chapter1introducestheconceptofanobject-orientedframework
andshowshowframeworksdifferfromotherreusetechniques,such
asclasslibraries,components,patterns,andmodel-integrated
computing.WethenoutlinetheframeworksintheACEtoolkitthat
arecoveredinsubsequentchapters.
Chapter2completesthedomainanalysisbeguninC++NPv1,which
coveredthecommunicationprotocolsandmechanisms,andthe
concurrencyarchitecturesusedbynetworkedapplications.The
focusinthisbookisontheserviceandconfigurationdesign
dimensionsthataddresskeynetworkedapplicationproperties,such
asdurationandstructure,hownetworkedservicesareidentified,and
thetimeatwhichtheyareboundtogethertoformcomplete
applications.
Chapter3describesthedesignanduseoftheACEReactor
framework,whichimplementstheReactorpattern[POSA2]toallow
event-drivenapplicationstodemultiplexanddispatchservice
requeststhataredeliveredtoanapplicationfromoneormore
clients.
Chapter4thendescribesthedesignanduseofthemostcommon
implementationsoftheACE_Reactorinterface,whichsupporta
widerangeofOSeventdemultiplexingmechanisms,including
select(),WaitForMultipleObjects(),
XtAppMainLoop(),and/dev/poll.
Chapter5describesthedesignanduseoftheACEService
Configuratorframework.ThisframeworkimplementstheComponent
Configuratorpattern[POSA2]toallowanapplicationtolink/unlinkits
componentserviceimplementationsatruntimewithouthavingto
modify,recompile,orrelinktheapplicationstatically.
Chapter6describesthedesignandeffectiveuseoftheACETask
framework.Thisframeworkcanbeusedtoimplementkey
concurrencypatterns,suchasActiveObjectandHalf-Sync/HalfAsync[POSA2].
Chapter7describesthedesignandeffectiveuseoftheACE
Acceptor-Connectorframework.Thisframeworkimplementsthe
Acceptor-Connectorpattern[POSA2]todecoupletheconnection
andinitializationofcooperatingpeerservicesinanetworkedsystem
fromtheprocessingtheyperformonceconnectedandinitialized.
Chapter8describesthedesignanduseoftheACEProactor
framework.ThisframeworkimplementstheProactorandAcceptorConnectorpatterns[POSA2]toallowevent-drivenapplicationsto
efficientlydemultiplexanddispatchservicerequeststriggeredbythe
completionofasynchronouslyinitiatedoperations.
Chapter9describesthedesignanduseoftheACEStreams
framework.ThisframeworkimplementsthePipesandFilterspattern
[POSA1]toprovideastructureforsystemsthatprocessstreamsof
data.
Thebookconcludeswithaglossaryoftechnicalterms,alistof
referencesforfurtherstudy,andageneralsubjectindex.
Thechaptersareorganizedtobuilduponeachotherandtominimize
forwardreferences.Wethereforerecommendthatyoureadthechapters
inorder.
AlthoughthisbookillustratesthekeycapabilitiesofACE'smostimportant
frameworks,wedon'tcoverallusesandmethodsofthoseframeworks.
ForadditionalcoverageofACE,wereferyoutoTheACEProgrammer's
Guide[HJS]andtheonlineACEreferencedocumentation,generatedby
Doxygen[Dim01].ACE'sreferencedocumentationisavailableat
and />
RelatedMaterial
ThisbookisbasedonACEversion5.3,releasedinthefallof2002.ACE
5.3andallthesampleapplicationsdescribedinourbooksareopensourcesoftware.Sidebar3(page19)explainshowyoucanobtainacopy
ofACEsoyoucanfollowalong,seetheactualACEclassesand
frameworksincompletedetail,andrunthecodeexamplesinteractively
asyoureadthebook.
TolearnmoreaboutACE,ortoreporterrorsyoufindinthebook,we
recommendyousubscribetotheACEmailinglist,YoucansubscribebysendingarequesttoIncludethefollowingcommandinthebody
ofthee-mail(thesubjectisignored):subscribeace-users
[emailaddress@domain]
Youmustsupplyemailaddress@domainonlyifyourmessage's
Fromaddressisnottheaddressyouwishtosubscribe.Ifyouusethis
alternateaddressmethod,thelistserverwillrequireanextra
authorizationstepbeforeallowingyoutojointhelist.
Postingstotheace-userslistarealsoforwardedtothe
comp.soft-sys.aceUSENETnewsgroup,alongwithpostingsto
severalotherACE-relatedmailinglists.Readingthemessagesviathe
newsgroupisagoodwaytokeepupwithACEnewsandactivityifyou
don'trequireimmediatedeliveryofthe30to50messagesthatare
posteddailyonthemailinglists.
Archivesofpostingstothecomp.soft-sys.acenewsgroupare
availableatEntercomp.soft-sys.ace
inthesearchboxtogotoalistofarchivedmessages.Googlehasa
complete,searchablearchiveofover40,000messages.Youcanalso
postamessagetothenewsgroupfromGoogle'ssite.